diff options
author | Nami-Doc <vendethiel@hotmail.fr> | 2014-07-16 20:07:35 +0200 |
---|---|---|
committer | Nami-Doc <vendethiel@hotmail.fr> | 2014-07-16 20:07:35 +0200 |
commit | 6a33cbd3aee825f4cc16c82c15963c66486d1834 (patch) | |
tree | 5cfa9defc2feb6a42d3b4c1954ea256cb62ed516 /perl6.html.markdown | |
parent | f97d9c5aba4b50911c0580cccbd3950be5192c01 (diff) |
Try to fix HL
Diffstat (limited to 'perl6.html.markdown')
-rw-r--r-- | perl6.html.markdown | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/perl6.html.markdown b/perl6.html.markdown index 057c74f8..7029de27 100644 --- a/perl6.html.markdown +++ b/perl6.html.markdown @@ -14,10 +14,6 @@ Perl 6 runs on [the Parrot VM](http://parrot.org/), the JVM and [the MoarVM](htt ```perl6 # Single line comment start with a pound -#`( - Multiline comments use #` and a quoting construct. (), [], {}, 「」, etc, will work. -) - ### Variables # In Perl 6, you declare a lexical variable using `my` @@ -88,9 +84,11 @@ sub truthy-array(@array) { # `-> {}` and `{}` are pretty much the same thing, except taht the former can take arguments, # and that the latter can be mistaken as a hash by the compiler -# You can also use the "whatever star" to create an anonymous function : +# You can also use the "whatever star" to create an anonymous function +# (it'll stop at the furthest operator in the current expression) map(*+3, @array); # `*+3` is the same as `{ $_ + 3 }` -map(*+*+3, @array); # also works. Same as `-> $a, $b -> { $a + $b + 3 }` +map(*+*+3, @array); # also works. Same as `-> $a, $b { $a + $b + 3 }` +say ((*+3)/5)(5); # immediatly execute the function Whatever created -- works even in parens ! # but if you need to have more than one argument (`$_`) in a block (without wanting to resort to `-> {}`), # you can also use the implicit argument syntax, `$^` : @@ -116,6 +114,9 @@ sayit(True); # fails at *compile time* with "calling 'sayit' will never work wit multi is-big(Int $n where * > 10) { True } multi is-big(Int $) { False } +# you can also name these checks, by creating "subsets" : +subset Even of Int where * %% 2; + ### Containers # In Perl 6, values are actually stored in "containers". # the assignment operator asks the container on the left to store the value on its right @@ -195,7 +196,6 @@ if long-computation() -> $result { } - ### Operators ## Since Perl languages are very much operator-based languages |