
2 Nov
2006
2 Nov
'06
12:32 p.m.
On 11/2/06, ajb@spamcop.net
G'day all.
Quoting Bernie Pope
: This is a weird example of a pattern binding, and it is surprising (to me) that the syntax is valid.
Maybe. But you wouldn't balk at this:
numzeroes xs = sum [ 1 | 0 <- xs ]
...even if you wouldn't naturally express it that way. Patterns like this are useful in places other than lets. I'd find it more surprising if lets were treated as a special case.
Actually, I had to try it out to see if it would work. That's a neat little trick. I had known that this similar one worked but it uses pattern matching on a data constructor so I never questioned it: numJusts xs = sum [ 1 | Just x <- xs ] thanks, Jason