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

Pages: 1-

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!

Name: Anonymous 2009-05-25 16:54

>>1
GTFO MY LAMBDA KNIGHTS NAO

Name: Anonymous 2009-05-25 16:54

>>1
GTFO MY LAMBDA KNIGHTS NAO

Name: Anonymous 2009-05-25 16:55

>>1
GTFO MY LAMBDA KNIGHTS NAO

Name: Anonymous 2009-05-25 16:55

>>1
GTFO MY LAMBDA KNIGHTS NAO

Name: Anonymous 2009-05-25 16:55

>>1
GTFO MY LAMBDA KNIGHTS NAO

Name: Anonymous 2009-05-25 16:55

>>1
Haskell is lazy, faggot.

Name: Anonymous 2009-05-25 17:00

delay e () = e
force = id
streamHead = head
streamTail = tail
streamNull = []
makeStream = map


Please don't re-invent the wheel!

Name: Anonymous 2009-05-25 17:11

>>8

Good call, but how do I implement memoization?

Name: Anonymous 2009-05-25 17:39

>>7
Who's a lazy faggot?

Name: Anonymous 2009-05-25 17:45

Listen, dickplotter; you fuqin angered me, penis-juggler, I hava never been trolled and FUQIN ANGERED this hard in my life, cockgorger. Did you meet your dong quota today, wangspinner? I bet you didn't, faggot.

Name: Anonymous 2009-05-25 18:19

penis-juggler

Name: Anonymous 2009-05-25 20:19

struct wangspinner

Name: Anonymous 2009-05-25 22:28

>>11
EXPERT PROGRAMMER detected.

Name: Anonymous 2009-05-26 16:00

Look who's talking. Ever heard of const?

Name: Anonymous 2009-05-26 18:46

I've decided to implement this via a monad instead. I'll post it when I finish.

Name: Anonymous 2009-05-26 18:51

You have a problem. Then you think, "I know, I'll make a monad." Now you have two problems.

Name: Anonymous 2009-05-26 19:00

I have experienced trolling.

Name: Anonymous 2011-02-15 16:49

>>1
I bamped in my pantsu.

Name: Anonymous 2011-02-15 17:05

The fuck, guys?

import Data.Stream

Name: Anonymous 2011-02-15 17:36

Shouldn't it be

delay e () = e
force e = e ()
streamHead e = head $ force e
streamTail e = tail $ force e
streamNull = delay []
makeStream _ [] = streamNull
makeStream f (h:t) = delay (f h: makeStream f t)


?

Or just, you know, use regular lists. Haskell is lazy, after all.

Name: Anonymous 2011-02-15 17:37

>>22
YHBT by a 2 years old thread

Name: Anonymous 2011-02-15 17:47

>>23
Better late than never.

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