Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Implementing Streams in Haskell

Name: Anonymous 2009-05-25 16:52

Streams are a higher-level, more straightforward way to think about programs. Haskell is a decent high-level language (which /prog/ seems to have a fetish for), so here's an implementation of streams in Haskell.


delay e = (\ () -> e)
force e = e
streamHead e = head $ force e
streamTail e = tail $ force e
streamNull = delay []
makeStream f l = (f $ head l):(delay $ makeStream f (tail l))


Have fun!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List