Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Menu/Raku/menu.raku
Normal file
18
Task/Menu/Raku/menu.raku
Normal 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue