[erlang-questions] list:join() for erlang?

David Budworth dbudworth@REDACTED
Wed Sep 12 18:56:02 CEST 2007


i'm guessing they mean join in the scripting language sense which is more
for creating CSV type strings.

ie (fictional function):
"I,Like,Erlang" = lists:join(["I","Like","Erlang"],",")

so join/2 would be something like (newbie alert, just started learning
erlang, so excuse the (possibly) bad code):

join([First|Rest],JoinWith) ->
   lists:flatten( [First] ++ [ JoinWith ++ X || X <- Rest] ).

calling join(["A","B","C"],"+")
would result in "A+B+C"


On 9/12/07, igwan <igwan@REDACTED> wrote:
>
> It does exist :
>
> erlang:'++'/2
>
> and the corresponding syntactic sugar :
>
> 1> [a,b,c] ++ [d,e,f].
> [a,b,c,d,e,f]
>
>
> -igwan
>
> Peter K Chan a écrit :
> > I looked around and I couldn't find a list:join() implementation for
> > erlang. Is this intentional? The join function seems to be a useful
> > feature to have.
> >
> > I ended up writing my own version, which was simple enough; but it would
> > be even better if it is available as a BIF.
> >
> > Peter
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070912/1b93ff3f/attachment.htm>


More information about the erlang-questions mailing list