This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub foo($a) { | |
multi sub when(Int:D $a) { say $a.WHAT; } | |
multi sub when(Str:D $s) { say $s.WHAT; } | |
multi sub when(|) { say ‘default’ } | |
when($a); | |
} | |
foo ('Answer', 42, Nil).all; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You are there: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
No such method 'add-colonpair' for invocant of type | |
'RakuAST::ColonPair::Value' | |
at SETTING::src/core.c/Exception.pm6:64 (/usr/local/src/rakudo/install/share/perl6/runtime/CORE.c.setting.moarvm:throw) | |
from src/Perl6/Metamodel/Configuration.nqp:60 (/usr/local/src/rakudo/install/share/perl6/lib/Perl6/Metamodel.moarvm:throw_or_die) | |
from src/vm/moar/dispatchers.nqp:676 (/usr/local/src/rakudo/install/share/perl6/lib/Perl6/BOOTSTRAP/v6c.moarvm:report-method-not-found) | |
from src/vm/moar/dispatchers.nqp:613 (/usr/local/src/rakudo/install/share/perl6/lib/Perl6/BOOTSTRAP/v6c.moarvm:) | |
from src/Raku/Actions.nqp:782 (/usr/local/src/rakudo/install/share/perl6/lib/Raku/Actions.moarvm:EXPR) | |
from NQP::src/HLL/Grammar.nqp:554 (/usr/local/src/rakudo/install/share/nqp/lib/NQPHLL.moarvm:EXPR_reduce) | |
from NQP::src/HLL/Grammar.nqp:514 (/usr/local/src/rakudo/install/share/nqp/lib/NQPHLL.moarvm:EXPR) | |
from <unknown>:1 (/usr/local/src/rakudo/install/share/perl6/lib/Raku/Grammar.moarvm:arglist) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6.*; | |
# my $a = '1 B'; | |
# | |
# if $a ~~ /(<digit>) \s (<alpha>)/ -> $_ { | |
# my ($one, $B) = .deepmap: *.Str; | |
# say "$one $B"; | |
# } | |
# | |
# if $a ~~ /(<digit>) \s (<alpha>)/ -> Match (Str() $one, Str() $B) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use uniname-words; | |
constant $stdin-text = qq:to/EOH/; | |
I ♥ Raku! | |
1 22 333 4444 55555 6565656 | |
3.14159265358979323846264338327950288419716939937510582097494459 | |
A line with the number 42. | |
We may need some "quotes". | |
A backslash \\ | |
would be nice too. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use uniname-words; | |
constant $stdin-text = qq:to/EOH/; | |
I ♥ Raku! | |
1 22 333 4444 55555 6565656 | |
3.14159265358979323846264338327950288419716939937510582097494459 | |
A line with the number 42. | |
We may need some "quotes". | |
A backslash \\ | |
would be nice too. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub limit-rate(Supply $in, $per-seconds = 1 --> Supply:D) { | |
my $out = Supplier::Preserving.new; | |
start react whenever $in -> \value { | |
$out.emit: value; | |
sleep(1 / $per-seconds); | |
} | |
$out.Supply; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6.d; | |
constant @keymap = (0x1b, 0x5b, 0x31, 0x31, 0x7e) => 'F1', (0x61,) => 'a', (0x0a,) => 'ENTER'; | |
use Term::ReadKey; | |
react { | |
whenever key-pressed( :!echo ) { | |
state @stack; | |
@stack.push: .ord; | |
# .ord.fmt('%02x').put; # uncomment to discover new keycodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multi sub MAIN(Bool :$S, Bool :$three) { | |
constant @months = <January February March April May June July August September October November December>; | |
my @week-days = $S ?? <Su Mo Tu We Th Fr Sa> !! <Mo Tu We Th Fr Sa Su>; | |
my &start-week-day = $S ?? { .[0].day-of-week % 7 } !! { .[0].day-of-week - 1 } | |
my $month-offset = $three ?? -1 !! 0; | |
loop { | |
$_ = now.Date.truncated-to('month'); | |
$_ = .earlier(:month(1)) if $three; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ub exclude(@a, $elems) { | |
say (0..^$elems).grep: * !~~ @a | |
} | |
my @a = 1..10; | |
@a[&exclude.assuming(2..3)].say; | |