
1 Mar
2009
1 Mar
'09
5:31 a.m.
Tom Poliquin wrote:
1) Is there a nice (canonical) way of eliminating nested evil in Haskell? I thought that perhaps making a tuple of all the if's conditions and patterm matching on them might make a bit more comprehensible. Likely there's a better way.
You probably want guards, like this fib n | n == 0 = 0 | n == 1 = 1 | otherwise = fib (n-1) + fib (n-2) Regards, apfelmus -- http://apfelmus.nfshost.com