Skip to content

Instantly share code, notes, and snippets.

@raydiak
Created December 20, 2014 07:33
Show Gist options
  • Save raydiak/cab66abb2738be47b2b8 to your computer and use it in GitHub Desktop.
Save raydiak/cab66abb2738be47b2b8 to your computer and use it in GitHub Desktop.
#!/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