[<<][compsci][>>][..]
Wed Sep 9 09:50:14 CEST 2009

Towards the best collection traversal interface

I find this idea quite intriguing, as it seems to be central to a lot
of things I'm trying to understand.  I'm putting the idea to the test
by trying to avoid lists wherever possible, and use left fold instead.

Enumerators are easily bridged to SRFI-41 lazy lists, eager lists and
PLT Scheme sequences.  The `enum->stream' operation uses reset/shift
to invert control as in:

 (define (enum->stream enum)
   (reset
    (enum (lambda (el)
            (shift k (stream-cons el (k #t)))))
    stream-null))

Example: the `choice' operator[3] in Staapl, which uses enumerators
for representing choices and results, making it easier to compose
searches.  (Internally, the choice enumerator is translated into a
lazy stack of resume points.)


[1] http://lambda-the-ultimate.org/node/1224
[2] http://okmij.org/ftp/Streams.html#enumerator-stream
[3] http://zwizwa.be/darcs/staapl/staapl/machine/choice.ss
[4] http://www.eros-os.org/pipermail/e-lang/2004-March/009643.html




[Reply][About]
[<<][compsci][>>][..]