Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created November 2, 2017 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/a4f23c4c647feaadbbe9ded22f514f5a to your computer and use it in GitHub Desktop.
Save zoffixznet/a4f23c4c647feaadbbe9ded22f514f5a to your computer and use it in GitHub Desktop.
# Infinite list of primes:
my @primes = ^∞ .grep: *.is-prime;
say "1001ˢᵗ prime is @primes[1000]";
# Lazily read words from a file
.say for '50TB.file.txt'.IO.words;
# No floating point noise:
say 0.1 + 0.2 == 0.3; # OUTPUT: True
say (1/13 + 3/7 + 3/8).perl; # OUTPUT: <641/728>
start { sleep 1.5; print "hi" }
await Supply.from-list(<A B C D E F>).throttle: 2, {
sleep 0.5;
.print
}
# OUTPUT: ABCDhiEF
grammar Parser {
rule TOP { I <love> <lang> }
token love { '♥' | love }
token lang { < Perl Rust Go Python Ruby > }
}
say Parser.parse: 'I ♥ Perl';
# OUTPUT: 「I ♥ Perl」 love => 「♥」 lang => 「Perl」
say Parser.parse: 'I love Rust';
# OUTPUT: 「I love Rust」 love => 「love」 lang => 「Rust」
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment