
On 08/23/10 15:02, Brandon S Allbery KF8NH wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 8/23/10 14:56 , Isaac Dupree wrote:
On 08/23/10 02:33, John Smith wrote:
Why doesn't Haskell allow something like this?
fac 0 = 0 1 = 1 x = x * fac (x-1)
This would be clearer than repeating the function name each time, and follow the same pattern as guards and case.
Layout is detected and parsed when and only when it is preceded by 'where', 'let', 'do', or 'of'. So Haskell would have to have some such keyword to
I think the next question is "so how do guards work?"
Weirdly! It's a bit like "|" is a prefix operator, at least when found in this relevant parsing-context (and not e.g. in a list comprehension). The guards don't need to line up either. I admit that I wasn't too happy when I found out how guards parse. "|" looks way too symmetric of a character for it to do that... Linebreaks are not required! : fac x | x==0 = 0 | x==1 = 1 | otherwise = x * fac (x-1)