On Thu, Sep 20, 2007 at 05:20:46PM +0400, Victor Nazarov wrote:
> I still can't remember how guards are treated in Haskell. Here is the
> code snippet in question:
> 
> foo a | a == 1 = 6
> foo a | a == 2 = 7
> foo a = 8
> 
> Would Haskell fall through to the third alternative if a is not equal
> to 1 or 2. I know that this can be rewritten more sanely, but I just
> consider guard behavior. What would be the value of (foo 3)?

8.

It falls through if no guards in a rhs match.

Stefan

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to