mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-05-05 06:18:32 +00:00
Try to fix HL
This commit is contained in:
parent
f97d9c5aba
commit
6a33cbd3ae
@ -14,10 +14,6 @@ Perl 6 runs on [the Parrot VM](http://parrot.org/), the JVM and [the MoarVM](htt
|
|||||||
```perl6
|
```perl6
|
||||||
# Single line comment start with a pound
|
# Single line comment start with a pound
|
||||||
|
|
||||||
#`(
|
|
||||||
Multiline comments use #` and a quoting construct. (), [], {}, 「」, etc, will work.
|
|
||||||
)
|
|
||||||
|
|
||||||
### Variables
|
### Variables
|
||||||
|
|
||||||
# In Perl 6, you declare a lexical variable using `my`
|
# 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 `{}` 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
|
# 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); # `*+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 `-> {}`),
|
# 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, `$^` :
|
# 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 $n where * > 10) { True }
|
||||||
multi is-big(Int $) { False }
|
multi is-big(Int $) { False }
|
||||||
|
|
||||||
|
# you can also name these checks, by creating "subsets" :
|
||||||
|
subset Even of Int where * %% 2;
|
||||||
|
|
||||||
### Containers
|
### Containers
|
||||||
# In Perl 6, values are actually stored in "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
|
# 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
|
### Operators
|
||||||
|
|
||||||
## Since Perl languages are very much operator-based languages
|
## Since Perl languages are very much operator-based languages
|
||||||
|
Loading…
Reference in New Issue
Block a user