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

Haskell

Name: Anonymous 2009-01-27 20:20

Please help with my Haskell code. It is supposed to return the maximum element in a list but it doesn't work

lol :: [a] -> Nothing | a
lol [] = Nothing
lol [x] = x
lol (x:xs) = if x > lol xs then x else lol xs

Name: Anonymous 2009-01-28 15:20

>>27
(hope I'm not answering to that coldsomething homo) the problem is not with recursion (that can be and sometimes is as fast as loops, you'd better read your SICP nao, until the Snake gets you), the problem is specifically with Haskell and its lazy evaluation by default policy.

I've thought about it for a while and I'm more or less sure that it's plain impossible to sum a million ints in haskell without using these heretical foldl' or seq. Prove me wrong please, okay, thanks.

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