-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstring0.pro
More file actions
38 lines (28 loc) · 810 Bytes
/
Copy pathstring0.pro
File metadata and controls
38 lines (28 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/** strings_join(Strings, String)
Strings is input.
Strings is a list of strings.
String is output.
Example:
strings_join(["abc", "def", "ghi"], "abcdefghi")
See also atomics_to_string/2.
*/
strings_join([], "") :- !.
strings_join([H|T], Output) :-
strings_join(T, S),
string_concat(H, S, Output).
/*
Consider the standard atomics_to_string/3 instead of this.
strings_separator_join(Strings, Separator, String)
This is unidirectional.
This can't be used to split strings.
Strings is input.
Strings is a list of strings.
Separator is a string.
String is output.
*/
strings_separator_join([], _, "") :- !.
strings_separator_join([H], _, H) :- !.
strings_separator_join([H|T], Sep, Str) :-
strings_separator_join(T, Sep, ST),
string_concat(H, Sep, SHS),
string_concat(SHS, ST, Str).