On 11/2/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
G'day all.

Quoting Bernie Pope <[EMAIL PROTECTED]>:

> 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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to