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-27 21:14

>>3
I have no idea. I obviously know nothing about Haskell's typing system, so I was trying to learn by example. The only reason I didn't try Maybe was because when I looked it up it talked about monads ands Just, neither of which I understand.

lol (x:xs) = if x > lol xs then x else lol xs
Thanks for the explanation. I kind of expected the runtime would be pig disgusting here. It was more of an attempt to get the function to compile than anything.

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