Compare commits

..

2 commits

Author SHA1 Message Date
drudge 17215128f0 ch4 done 2023-11-23 08:26:32 -08:00
drudge 0aa20f6d85 4-4 2023-11-23 07:56:38 -08:00
4 changed files with 35 additions and 0 deletions

6
ch4/ex4-4.raku Normal file
View 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
View 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
View 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
View 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';
}