diff --git a/ch3/ex3-1.raku b/ch3/ex3-1.raku new file mode 100644 index 0000000..72f2f76 --- /dev/null +++ b/ch3/ex3-1.raku @@ -0,0 +1,5 @@ +say 137.^name; +say (-17).^name; +say 3.14.^name; +say 6.026e34.^name; +say (0+i).^name; diff --git a/ch3/ex3-2.raku b/ch3/ex3-2.raku new file mode 100644 index 0000000..269aa09 --- /dev/null +++ b/ch3/ex3-2.raku @@ -0,0 +1,6 @@ +# Take 2 arguments from command line, output their types + +sub MAIN ($arg1, $arg2) { + say "arg1 type is {$arg1.^name}"; + say "arg2 type is {$arg2.^name}"; +} diff --git a/ch3/ex3-3.raku b/ch3/ex3-3.raku new file mode 100644 index 0000000..75b5464 --- /dev/null +++ b/ch3/ex3-3.raku @@ -0,0 +1,12 @@ +# create a program that reports the type of number specified on the command line using 'given' block + +sub MAIN ($number) { + given $number { + say "Number type: ", do given $number { + when Int { 'integer' } + when Complex { 'complex' } + when Rat { 'rat' } + default { 'unsupported type' } + } + } +}