Skip to content

Instantly share code, notes, and snippets.

@zengargoyle
Last active December 11, 2018 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zengargoyle/c37970b0050053f653d923d961c69660 to your computer and use it in GitHub Desktop.
Save zengargoyle/c37970b0050053f653d923d961c69660 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
class P {
has $.x;
has $.y;
has $.vx;
has $.vy;
}
sub Pprint (@p is copy) {
use Terminal::Print;
my $xoff = @p.map(*.x).min;
my $yoff = @p.map(*.y).min;
@p .= map({.x - $xoff, .y -$yoff});
my $s = Terminal::Print.new;
$s.initialize-screen;
for @p -> ($x,$y) {
$s.print-cell($x,$y,'*');
# $s.shutdown-screen;
}
}
my @P = do for "small".IO.lines.comb(/'-'?\d+/)>>.Int -> $x,$y,$vx,$vy { P.new: :$x, :$y, :$vx, :$vy }
Pprint(@P);
my $xoff = @p.map(*.x).min;
my $yoff = @p.map(*.y).min;
say "$xoff $yoff";
say @p.map({.x, .y});
-2 -2
((9 1) (7 0) (3 -2) (6 10) (2 -4) (-6 10) (1 8) (1 7) (-3 11) (7 6) (-2 3) (-4 3) (10 -3) (5 11) (4 7) (8 -2) (15 0) (1 6) (8 9) (3 3) (0 5) (-2 2) (5 -2) (1 4) (-2 7) (3 6) (5 0) (-6 0) (5 9) (14 7) (-3 6))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment