Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

18
Task/Menu/Raku/menu.raku Normal file
View file

@ -0,0 +1,18 @@
sub menu ( $prompt, @items ) {
return '' unless @items.elems;
repeat until my $selection ~~ /^ \d+ $/ && @items[--$selection] {
my $i = 1;
say " {$i++}) $_" for @items;
$selection = prompt $prompt;
}
return @items[$selection];
}
my @choices = 'fee fie', 'huff and puff', 'mirror mirror', 'tick tock';
my $prompt = 'Enter the number corresponding to your selection: ';
my $answer = menu( $prompt, [] );
say "You chose: $answer" if $answer.chars;
$answer = menu( $prompt, @choices );
say "You chose: $answer" if $answer.chars;