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

/PROG/SICP CHALLENGE

Name: Anonymous 2008-09-01 7:21

IMPLEMENT THE COLLECTOR!!!

(((((o) 'a) 'b) 'c)) ; => (a b c)

Name: Anonymous 2008-09-01 11:13

class Collect a where
  collect :: ([Int] -> [Int]) -> a

instance Collect [Int] where
  collect acc = acc []

instance (Integral t, Collect b) => Collect (t -> b) where
  collect acc x = collect (acc . (fromIntegral x:))


*Main> o 1 2 3 :: [Int]
[1,2,3]


o :: (Collect a) => a
o = collect id

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