diff options
| -rw-r--r-- | challenge-011/ozzy/perl6/ch-1.p6 | 14 | ||||
| -rw-r--r-- | challenge-011/ozzy/perl6/ch-2.p6 | 21 |
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-011/ozzy/perl6/ch-1.p6 b/challenge-011/ozzy/perl6/ch-1.p6 new file mode 100644 index 0000000000..656cf2aca4 --- /dev/null +++ b/challenge-011/ozzy/perl6/ch-1.p6 @@ -0,0 +1,14 @@ +#!/usr/bin/env perl6 + +sub T_F ( Num $T_C ) { $T_C * (212-32)/100 + 32 } +sub T_C ( Num $T_F ) { ($T_F - 32) * 100/(212-32) } + +sub MAIN ( + Str $T #= Temperature +) +{ + my $Tn = $T.Num; + + printf("%7.2f degrees Celcius is equal to %7.2f degrees Fahrenheit.\n", $Tn, T_F($Tn)); + printf("%7.2f degrees Fahrenheit is equal to %7.2f degrees Celcius.\n", $Tn, T_C($Tn)); +} diff --git a/challenge-011/ozzy/perl6/ch-2.p6 b/challenge-011/ozzy/perl6/ch-2.p6 new file mode 100644 index 0000000000..346fc299d2 --- /dev/null +++ b/challenge-011/ozzy/perl6/ch-2.p6 @@ -0,0 +1,21 @@ +#!/usr/bin/env perl6 +# +# Compose and print identity matrix +# +# Notes: +# - "is default" trait not implemented for shaped arrays +# - Partially dimensioned views of shaped arrays not yet implemented +# - Could use Math::Matrix + +sub MAIN (Int $dim) +{ + my @md[$dim;$dim]; + + for 0..$dim-1 -> $i { + for 0..$dim-1 -> $j { + @md[$i;$j]= $i==$j ?? 1 !! 0; + printf "%3i", @md[$i;$j]; + } + printf "\n"; + } +} |
