- 论坛徽章:
- 2
|
你需要多少时间习惯?
----------------------------------------------------------------------
say [+] 1, 2, 3; # 6
say [+] (); # 0
say [~] <a b>; # ab
say [**] 2, 3, 4; # 2417851639229258349412352
[\+] 1, 2, 3, 4 # 1, 3, 6, 10
[\**] 2, 3, 4 # 4, 81, 2417851639229258349412352
if [<=] @list {
say "ascending order";
}
----------------------------------------------------------------------
if [==] @nums { say "all nums in @nums are the same" }
elsif [<] @nums { say "@nums is in strict ascending order" }
elsif [<=] @nums { say "@nums is in ascending order"}
----------------------------------------------------------------------
subset Squares of Int where { .sqrt.int**2 == $_ };
multi sub square_root(Squares $x --> Int) {
return $x.sqrt.int;
}
multi sub square_root(Num $x --> Num) {
return $x.sqrt;
}
----------------------------------------------------------------------
my @integers = 0..*;
for @integers -> $i {
say $i;
last if $i % 17 == 0;
}
my @even = map { 2 * $_ }, 0..*;
my @stuff = gather {
for 0 .. Inf {
take 2 ** $_;
}
}
----------------------------------------------------------------------
my $file = open '/etc/passwd', :r;
for $file.lines -> $line {
say $line;
}
---------------------------------------------------------------------- |
|