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

t ty tty.erlang@REDACTED
Wed Sep 12 19:29:21 CEST 2007


I have 4 versions of this variant in my application source base: from
tsung, yaws, oserl and one written in house. I definitely vote to have
this in either string or lists.

t

On 9/12/07, David Budworth <dbudworth@REDACTED> wrote:
> 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
> >
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list