in reply to
Re^11: 99 Problems in Perl6
in thread 99 Problems in Perl6
Similar syntax exists in Haskell and is called a guard.
-- Here the |s should be read as one vertical line, like a mathematica
+l function def.
fact n | n == 0 = 1
| otherwise = n * fact (n - 1)
-- Here's the same thing in different style, the same one as I'd used
-- called "declarative", sometimes called direct pattern matching, bec
-- variant gets to bind whatever it managed to match.
fact 0 = 1
fact n = n * fact (n - 1)
There are plenty of non-syntactic variations on this theme
. The scanl one is my favorite.