RosettaCodeData/Task/Higher-order-functions/Perl-6/higher-order-functions.pl6
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

17 lines
282 B
Raku

sub twice(&todo) {
todo(); todo(); # declaring &todo also defines bare function
}
twice { say "Boing!" }
# output:
# Boing!
# Boing!
sub twice-with-param(&todo) {
todo(0); todo(1);
}
twice-with-param -> $time {
say "{$time+1}: Hello!"
}
# output:
# 1: Hello!
# 2: Hello!