Definition: | sequence res = join(sequence s, object delim=" ") |
Description: | Concatenate all top-level elements of s. Optionally, a delimiter can be specified to
be placed between each element. If you do not need a delimeter, specify "" or {}.
Returns a string or sequence. |
Comments: | join is much more suited to string processing than flatten. |
Example 1: | Using the delimiter argument. |
s = join({"abc", "def", "ghi"}, ", ") -- s is "abc, def, ghi" s = join({"one", "two", "three"}, "\n") -- (or '\n') -- s is "one\ntwo\nthree" Exactly the same result is returned whether the delimiter is a single (ascii) character, or the matching string of length 1. |
|
Example 2: | If no delimeter is required, specify a null string or an empty sequence. |
s = join({"one\n", "two\n", "three\n"}, "") -- s is "one\ntwo\nthree\n" |
|
Example 3: | join is not restricted to string processing. |
s = join({{1,"file1"},{2,"file2"},{1,"file3"},{3,"file4"}},{}) -- s is {1,"file1",2,"file2",1,"file3",3,"file4"} ptrsets = {{#040010B8,#040012C4,#0400106C},{#040011A0},{#0400147A,#0400100A}} inorder = sort(join(ptrsets,{})) -- (might be one for flatten though) -- inorder is {#0400100A,#0400106C,#040010B8,#040011A0,#040012C4,#0400147A} |
|
See Also: | flatten, columnize, join_path |