# join

Definition: | sequence res = join(sequence s, object delim=" ", lastdelim=delim, string fmt="")
Description: | Concatenate all top-level elements of s. Optionally, a delimiter can be specified to be placed between each element, and an override for the last one. If you do not need a delimeter, specify "" or {}. Fairly obviously if a non-empty fmt is provided it is applied, via sprintf(), to each element of s as part of the joining process. Returns a string or sequence.
pwa/p2js: | Supported.
Comments: | join is much more suited to string processing than flatten.
Example 1: | Using the delimiter argument(s). When specified lastdelim is typically either " and " or ", and ".
    s = join({"one", "two", "three"}, ", ", ", and ")
    -- s is "one, two, and three"
Exactly the same result is returned whether the delimiter is a single (ascii) character, or the matching string of length 1, so for example you could use either "\n" or '\n'.
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}
Implementation: | See builtins\pflatten.e (an autoinclude) for details of the actual implementation.
See Also: | flatten, columnize, join_path