-
-
Save zoffixznet/a4f23c4c647feaadbbe9ded22f514f5a to your computer and use it in GitHub Desktop.
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
# 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; | |
} | |
# 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