[Haskell-beginners] Re: Finite State Machine ..

Heinrich Apfelmus apfelmus at quantentunnel.de
Sun Mar 1 05:31:45 EST 2009


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



More information about the Beginners mailing list