Created
September 9, 2023 17:39
-
-
Save lucs/1df6ca5baae45230ee38d476168dc933 to your computer and use it in GitHub Desktop.
Example snippets to use with snipraku.raku
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
# -------------------------------------------------------------------- | |
# ID: misc79 unicode | |
for ^2**20 -> $u { | |
my $c = chr $u; | |
my $n = uniname $c; | |
printf "$c U-%X %s\n", $u, $n if $n ~~ /'SNOW'/; | |
} | |
# -------------------------------------------------------------------- | |
# ID: rx36 | |
sub eg ($str) { | |
say $str; | |
for $str.comb: / <-[",]>+ | \" ~ \" <-["]>+ / -> $f { | |
say " $f"; | |
} | |
} | |
eg 「a,"1,725.34",b」; | |
=finish | |
Prints: | |
a,"1,725.34",b | |
a | |
"1,725.34" | |
b | |
# -------------------------------------------------------------------- | |
# ID: x1 Omit parentheses to call a function. | |
sub foo { say "FOO" } | |
# s() same as foo(); | |
my &s = &foo; | |
s; | |
# Anonymous sub stored in variable, and used as a sub. | |
my &s2 = sub { say "s2" } | |
s2; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment