Created
July 26, 2021 17:54
-
-
Save treyharris/4b3be9223245395d21bfdc62579d0331 to your computer and use it in GitHub Desktop.
Playing with Raku Rat and sqrt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rat's type is Rat | |
z's type is Rat | |
13 6 squared= 169 36 | |
Rat(169 36)'s sqrt, 2.1666666666666665, is a Num, but coerced, is Rat(13 6) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $x = 13; | |
my $y = 6; | |
my $rat = Rat($x/$y); | |
my $z = $rat**2; | |
say "rat's type is ", $rat.^name; | |
say "z's type is ", $z.^name; | |
say "{$rat.nude} squared= {$z.nude}"; | |
my $root = sqrt($z); | |
say "Rat({$z.nude})'s sqrt, $root, is a {$root.^name}, but coerced, is Rat({Rat($root).nude})"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment