ch3 progress
This commit is contained in:
parent
55b2d1d21f
commit
f12da1bc9b
5
ch3/ex3-1.raku
Normal file
5
ch3/ex3-1.raku
Normal file
|
@ -0,0 +1,5 @@
|
|||
say 137.^name;
|
||||
say (-17).^name;
|
||||
say 3.14.^name;
|
||||
say 6.026e34.^name;
|
||||
say (0+i).^name;
|
6
ch3/ex3-2.raku
Normal file
6
ch3/ex3-2.raku
Normal file
|
@ -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}";
|
||||
}
|
12
ch3/ex3-3.raku
Normal file
12
ch3/ex3-3.raku
Normal file
|
@ -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' }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue