in reply to Re^9: 99 Problems in Perl6
in thread 99 Problems in Perl6
This is incredibly useful sometimes. Okay, when I want when I know where to find it. :-)funky (x:y:xs) = ... -- I'm guaranteed to have two elements or more funky (x:xs) = ... {- This pattern would have matched a long list, b +ut since the previous variant came first, we know the l +ist is of length 1 or 2. * -}
* For folks not familiar with Haskell who count three or two items in the two patterns and don't see why I'm talking of lists of at least two and one or two elements respectively: in Haskell, "(a:b)" means a is an element and b is a list of zero or more elements. That's why by convention you see names like "xs" and "ys", pronounced "exes" and "whys", though there's nothing in the language to enforce names like that. The expression (x:y:xs) means (x:(y:xs)).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: 99 Problems in Perl6
by ambrus (Abbot) on Dec 17, 2006 at 10:23 UTC | |
by gaal (Parson) on Dec 17, 2006 at 18:04 UTC |