Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^12: 99 Problems in Perl6

by gaal (Parson)
on Dec 17, 2006 at 18:04 UTC ( #590327=note: print w/ replies, xml ) Need Help??


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 +earlier and -- called "declarative", sometimes called direct pattern matching, bec +ause each -- 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.


Comment on Re^12: 99 Problems in Perl6
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://590327]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2015-07-04 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls