Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: extend-dump
Fetching contributors…

Cannot retrieve contributors at this time

file 23 lines (21 sloc) 0.762 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
## Order enumeration, for cmp and <=>
my enum Order (:Increase(-1), :Same(0), :Decrease(1));

proto infix:<cmp>($, $) { * }
multi infix:<cmp>(\a, \b) {
    return Order::Increase if a === -$Inf || b === $Inf;
    return Order::Decrease if a === $Inf || b === -$Inf;
    a.Stringy cmp b.Stringy
}
multi infix:<cmp>(Real \a, Real \b) { a.Bridge cmp b.Bridge }
multi infix:<cmp>(Int:D \a, Int:D \b) {
    Order.(nqp::p6box_i(nqp::cmp_I(nqp::p6decont(a), nqp::p6decont(b))))
}
multi infix:<cmp>(int $a, int $b) {
    Order.(nqp::p6box_i(nqp::cmp_i($a, $b)))
}

multi infix:«<=>»(Int:D \a, Int:D \b) {
    Order.(nqp::p6box_i(nqp::cmp_I(nqp::p6decont(a), nqp::p6decont(b))))
}
multi infix:«<=>»(int $a, int $b) {
    Order.(nqp::p6box_i(nqp::cmp_i($a, $b)))
}
Something went wrong with that request. Please try again.