Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (25 sloc) 984 Bytes
=begin pod
=TITLE role Rational
role Rational[::NuT, ::DenomT] does Real { ... }
C<Rational> is the common role for numbers that are stored as pairs of
numerator and denominator. It is parameterized by the types of the numerator
and denominator.
Built into Perl 6 are L<Rat> and L<FatRat>, which both do the C<Rational> role.
=head1 methods
=head2 new
method new(NuT:D $numerator, DenomT:D $denominator) returns Rational:D
Creates a new rational object from numerator and denominator.
=head2 numerator
method numerator(Rational:D:) returns NuT:D
Returns the numerator.
=head2 denominator
method denominator(Rational:D:) returns DenomT:D
Returns the denominator.
=head2 nude
method nude(Rational:D:) returns Positional
Returns a list of the numerator and denominator.
=head2 norm
method norm(Rational:D:) returns Rational:D
Returns a normalized Rational object, ie with positive denominator, and
numerator and denominator coprime.
=end pod
Jump to Line
Something went wrong with that request. Please try again.