This week's LFE Friday was translated with permission from the Erlang Thursday series by Steven Proctor. This week's translator: Robert Virding.

Today's LFE Friday is on string:join/2.

string:join/2 takes a list of strings as its first argument, and a string separator used to join the strings together into a single string.

> (string:join '("a" "b" "c") "")
> (string:join '("a" "b" "c") "-")

The separator string can be a string of any length, and doesn't just have to be a single character.

> (string:join '("a" "b" "c") "___")
> (string:join '("a" "b" "c") " ")  
"a b c"

And as with any string, a list of characters, or even integers, can be used as the separator string.

> (string:join '("a" "b" "c") '(#\A))
> (string:join '("a" "b" "c") '(52)) 

-Proctor, Robert



20 February 2015