blob: a9c39e8bea10df5cb9a78883701b57e86b12cf58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#! /usr/bin/env raku
my $value = 0;
my %dispatch;
%dispatch<q> = %dispatch<quit> = { exit };
%dispatch<d> = %dispatch<double> = { $value *= 2 };
%dispatch<h> = %dispatch<half> = { $value /= 2 };
%dispatch<c> = %dispatch<clear> = { $value = 0 };
%dispatch<s> = %dispatch<set> = { $value = $0.Int if @_[0] ~~ /^(\d)$/ };
%dispatch<help> = { say "Please consult a doctor." };
loop
{
my @command = (prompt "[$value]: ").words;
if %dispatch{@command[0]} { @command[1] ?? %dispatch{@command[0]}(@command[1]) !! %dispatch{@command[0]}() }
}
|