diff --git a/ch2/ex2-1.raku b/ch2/ex2-1.raku new file mode 100644 index 0000000..c5c5246 --- /dev/null +++ b/ch2/ex2-1.raku @@ -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!'; +} diff --git a/ch2/ex2-11.raku b/ch2/ex2-11.raku new file mode 100644 index 0000000..6438eb1 --- /dev/null +++ b/ch2/ex2-11.raku @@ -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"; +} diff --git a/ch2/ex2-2.raku b/ch2/ex2-2.raku new file mode 100644 index 0000000..af6ffd1 --- /dev/null +++ b/ch2/ex2-2.raku @@ -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"; +} diff --git a/ch2/ex2-3.raku b/ch2/ex2-3.raku new file mode 100644 index 0000000..9cbd084 --- /dev/null +++ b/ch2/ex2-3.raku @@ -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"; +} diff --git a/ch2/ex2-8.raku b/ch2/ex2-8.raku new file mode 100644 index 0000000..92c518d --- /dev/null +++ b/ch2/ex2-8.raku @@ -0,0 +1,10 @@ +# exercise modified to actually test +my $sum = 0; +for ^10 { + put ++$sum; +} + +my $sum2 = 0; +for ^10 { + put $sum2++; +} diff --git a/ch2/ex2-9.raku b/ch2/ex2-9.raku new file mode 100644 index 0000000..44e9d0e --- /dev/null +++ b/ch2/ex2-9.raku @@ -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; +} +}