[erlang-questions] List to proplist?

Bengt Kleberg bengt.kleberg@REDACTED
Wed Oct 29 13:41:46 CET 2008


Greetings,

The unfold/2 below seems to take a fun. Many functions in the lists
module take their fun as the first argument. For consistency it would
perhaps be a good idea to let unfold/2 also takes the fun as its first
argument?

This is all provided that Splitter is a fun, of course.


bengt

On Wed, 2008-10-29 at 13:15 +0100, Hans Bolinder wrote:
> [Richard O'Keefe:]
> > A version of unfold that I prefer is
> > 
> > unfold(State, Splitter) ->
> >      unfold(State, Splitter, []).
> > 
> > unfold(State, Splitter, Acc) ->
> >      case Splitter(State)
> >        of []            -> lists:reverse(Acc)
> >         ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc])
> >      end.
> 
> Thanks!
> 
> lists:unfold/2 has been added to the upcoming R12B-5 release.
> 
> Best regards,
> 
> Hans Bolinder, Erlang/OTP team, Ericsson
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list