Mon Oct 16 13:27:59 CEST 2000
i did experiment a bit on lazy lists ( following
(basically, did map and fold, and so on)
and i found it interesting . still:
- i found them not making things more easy ( but this argument mail fall short
, if an official lazy_list module exists, as it then becomes standard) ( and i
was contemeplating the fact im newby to FP, which may hinder some hidden
complex aspects) .
- some powerful things could be done( but tricky).
(e.g: when "walking " a tree/graph, the walking function can be depending of
the node, like a "strategy pattern") this is powerful, but tricky to read
- in a similar manner to uffe statement, my lazy walk was walking a non
existing tree yet, as it was following a db schema , loading mnesia data as it
went. the good point is that is was loading just as necessary ( rather than
loading half of the db, to later retain one 10th of it) (same issue when
walking xml files).
i finally stops my investigations, but i can dig out the code in my cvs, if
One thing id thought about was to enable a HOF on tree and graph ( like map
and fold for list), but wasnt dependent of the underlying data strucuture ( the
fun hides it for u)).
a walk/insert/delete... can be paramtrized by
-one function to walk the node
-one to "do the job " u wanna do on it.
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.
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
Richard Carlsson () (This space intentionally left blank.)
E-mail: WWW: http://www.csd.uu.se/~richardc/
More information about the erlang-questions