Algorithmic lists
Richard Carlsson
richardc@REDACTED
Mon Oct 16 12:56:00 CEST 2000
On Mon, 16 Oct 2000, Ulf Wiger wrote:
> We (a few lunatics at AXD 301) would like to see the lists module
> support an alternative formulation of lists.
>
> A list could be expressed in the following manner:
>
> [Head | fun(Head, F)]
>
> [...]
>
> What'ya think? Awful? Elegant?
>
>
> BTW, Joe already posted something like this on the erlang-questions
> list in March '99, but he was using zero-argument funs.
>
> http://www.erlang.org/ml-archive/erlang-questions/199903/msg00013.html
They are indeed elegant, and Joe was correct - they're called lazy lists,
and should be implemented using zero-argument funs. To give a type
declaration of sorts:
LazyList :: [] | [term() | fun() -> LazyList]
Writing a module 'lazy_lists' should be a doddle. In fact, I might do it
myself.
/Richard Carlsson
Richard Carlsson (richardc@REDACTED) (This space intentionally left blank.)
E-mail: Richard.Carlsson@REDACTED WWW: http://www.csd.uu.se/~richardc/
More information about the erlang-questions
mailing list