Compare commits
2 commits
a16d53070c
...
17215128f0
Author | SHA1 | Date | |
---|---|---|---|
drudge | 17215128f0 | ||
drudge | 0aa20f6d85 |
6
ch4/ex4-4.raku
Normal file
6
ch4/ex4-4.raku
Normal file
|
@ -0,0 +1,6 @@
|
|||
sub MAIN ($num1, $num2) {
|
||||
say "sum is {$num1 + $num2}";
|
||||
say "difference is {$num1 - $num2}";
|
||||
say "product is {$num1 * $num2}";
|
||||
say "quotient is {$num1 / $num2}";
|
||||
}
|
14
ch4/ex4-5.raku
Normal file
14
ch4/ex4-5.raku
Normal file
|
@ -0,0 +1,14 @@
|
|||
sub MAIN (
|
||||
$num1, #= Number to perform arithmatic on
|
||||
$num2 #= Second number to perform arithmatic on
|
||||
) {
|
||||
die "unexpected input" unless is-numeric($num1) and is-numeric($num2);
|
||||
say "sum is {$num1 + $num2}";
|
||||
say "difference is {$num1 - $num2}";
|
||||
say "product is {$num1 * $num2}";
|
||||
say "quotient is {$num1 / $num2}";
|
||||
}
|
||||
|
||||
sub is-numeric ($num) {
|
||||
return val($num) ~~ Numeric;
|
||||
}
|
5
ch4/ex4-6.raku
Normal file
5
ch4/ex4-6.raku
Normal file
|
@ -0,0 +1,5 @@
|
|||
sub MAIN (
|
||||
$my-string #= String to count characters/display
|
||||
) {
|
||||
say "$my-string has {$my-string.chars} characters";
|
||||
}
|
10
ch4/ex4-7.raku
Normal file
10
ch4/ex4-7.raku
Normal file
|
@ -0,0 +1,10 @@
|
|||
sub MAIN () {
|
||||
# Unset PATH for shell safety (pg. 68)
|
||||
%*ENV<PATH> = '';
|
||||
print Q :x 'C:\Windows\System32\hostname.exe' if $*DISTRO.is-win;
|
||||
print Q :x '/bin/hostname' unless $*DISTRO.is-win;
|
||||
|
||||
#avoid variable inputs for shell scripts
|
||||
#qqx/date $my-new-date/
|
||||
#my $my-new-date = '; /bin/rm -rf';
|
||||
}
|
Loading…
Reference in a new issue