ch2 done. Skipped math stuff

This commit is contained in:
drudge 2023-11-11 19:03:05 -08:00
parent dc0ce96f2a
commit 55b2d1d21f
6 changed files with 47 additions and 0 deletions

5
ch2/ex2-1.raku Normal file
View file

@ -0,0 +1,5 @@
# create both versions of the "Hello Perl 6" program, a one line version and MAIN version
say 'Hello Raku';
sub MAIN {
say 'Hello Perl 6!';
}

9
ch2/ex2-11.raku Normal file
View file

@ -0,0 +1,9 @@
# fizzbuzz
# Multiples of three output fizz, multiple sof five output buzz, and multiples of both output fizzbuzz
for ^100 {
print $_ + 1 ~ ":";
print "Fizz" if ($_ + 1) %% 3;
print "Buzz" if ($_ + 1) %% 5;
print "\n";
}

7
ch2/ex2-2.raku Normal file
View file

@ -0,0 +1,7 @@
# Create a program that takes three command-line arguments and outputs them on separate, numbered linles. Give two fo the parameters default values
sub MAIN ($param1, $param2="two", $param3="three") {
say "1. PARAM1: $param1";
say "2. PARAM2: $param2";
say "3. PARAM3: $param3";
}

6
ch2/ex2-3.raku Normal file
View file

@ -0,0 +1,6 @@
#Write a program that asks for a name and greets that name. Only prompt for name if an argument isn't supplied
sub MAIN ($name=prompt "wats ur name?\n") {
say "ohi $name";
}

10
ch2/ex2-8.raku Normal file
View file

@ -0,0 +1,10 @@
# exercise modified to actually test
my $sum = 0;
for ^10 {
put ++$sum;
}
my $sum2 = 0;
for ^10 {
put $sum2++;
}

10
ch2/ex2-9.raku Normal file
View file

@ -0,0 +1,10 @@
# Write a looping program to output a customizable multiple
sub MAIN ($multiple=3) {
loop {
state $sum = 0;
say $sum;
$sum += $multiple;
last if $sum > 20;
}
}