lambda fun: infinite streams

Magnus L. Hetland mlh at idt.ntnu.no
Sun Aug 8 09:42:03 EDT 1999


thantos at brimstone.mecha (Alexander Williams) writes:

> On Fri, 06 Aug 1999 20:53:21 -0700, Joe Bowbeer <joeb at go2net.com> wrote:
[...]
> Its good to see other Scheme/Fnctional-language freaks hanging around
> with the Python folks, especially those with copies of SICP.
> 
> Now, if only Python had lazy evaluation and Streams as first-class
> entities, my life would be complete.

Wow... ;)

> My life would be decently
> complete anyway if map() worked on your infinite streams as stands.
> ;)
> 

Well... You could make one yourself...

<treading carefully, as I am not really a functional programmer...
Dropping the multiple stream version for now:>


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


--

  Magnus              Making no sound / Yet smouldering with passion
  Lie          The firefly is still sadder / Than the moaning insect
  Hetland                                       : Minamoto Shigeyuki




More information about the Python-list mailing list