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:
Anonymous2009-01-28 16:40
I've found that performance problems in Haskell were (more often than not) caused by not understanding the implications of laziness and how it affects the cost of certain algorithms. I've seen numerous cases when a strict algorithm was faster/used less memory than my initial naive implementation. In most cases, I managed to analyse the algorithm and refactor into a lazy algorithm that performs just as well.
I don't really blame people for not understanding laziness as well as they should, it is truly a tool that is one level above the rest.