Skip to content

Instantly share code, notes, and snippets.

Created August 6, 2010 03:57
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 anonymous/510813 to your computer and use it in GitHub Desktop.
Save anonymous/510813 to your computer and use it in GitHub Desktop.
multi sub infix:«cmp»(Numeric $a, Numeric $b) { $a <=> $b; }
multi sub infix:«<=>»(Numeric $a, Numeric $b) {
my @a = $a.reals;
my @b = $b.reals;
@a.push(0 xx +@b - +@a) if (+@a < +@b);
@b.push(0 xx +@a - +@b) if (+@b < +@a);
[||] (@a Z<=> @b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment