lambda fun: infinite streams

Alexander Williams thantos at brimstone.mecha
Mon Aug 9 04:54:18 CEST 1999


On 08 Aug 1999 15:42:03 +0200, Magnus L. Hetland <mlh at idt.ntnu.no> wrote:
>Well... You could make one yourself...

True, but it wouldn't have the speed of the built-in map implimented
in C, would it?  :)

(Yes, longing for such things is left over from tinkering with
Haskell; there are so many algorithms that fall to simple expression
applied to Streams and lazy-evaluation.)

>def mapStream(f,s):
>    return (apply(f,[head(s)]),
>           lambda f=f, s=s: mapStream(f,tail(s)))

Hmmmmm, that should certainly work ...

I'm tempted to try and get Stackless Python working with this just to
see what kind of interaction it'd have.

-- 
Alexander Williams (thantos at gw.total-web.net)
"In the end ... Oblivion Always Wins."




More information about the Python-list mailing list