Created
December 20, 2014 07:33
-
-
Save raydiak/cab66abb2738be47b2b8 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env perl6 | |
use v6; | |
class Point { | |
has num $.x; | |
has num $.y; | |
method new(num $x, num $y ) { | |
self.bless: :$x, :$y; | |
} | |
method add(Point $b) { | |
self.bless: :x($!x + $b.x), :y($!y + $b.y); | |
} | |
method add-in(Point $b) { | |
$!x = $!x + $b.x; | |
$!y = $!y + $b.y; | |
self; | |
} | |
} | |
my int $i = 0; | |
my Point $a = Point.new(1.5e0, 2.5e0); | |
my Point $b = Point.new(3.25e0, 4.75e0); | |
while $i < 100000 { | |
#$a = $a.add($b).add($b); | |
$a.add-in($b).add-in($b); | |
$i = $i + 1; | |
} | |
say $a.perl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment