Last active
May 25, 2016 18:39
-
-
Save dogbert17/c8891f3ea49171618e01d27a159152a4 to your computer and use it in GitHub Desktop.
Attempt to document methods abs, conj, gist and perl in class Complex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 method abs | |
Defined as: | |
method abs(Complex:D:) returns Num:D | |
multi sub abs(Complex:D $z) returns Num:D | |
Usage: | |
COMPLEX.abs | |
abs COMPLEX | |
Returns the absolute value of the invocant (or the argument in sub form). | |
For a given complex number C<$z> the absolute value C<|$z|> is defined as | |
C<sqrt($z.re * $z.re + $z.im * $z.im)>. | |
say (3-4i).abs; # sqrt(3*3 + 4*4) == 5 | |
=head2 method conj | |
Defined as: | |
method conj(Complex:D:) returns Complex:D | |
Usage: | |
COMPLEX.conj | |
Returns the complex conjugate of the invocant (that is, the number with the | |
sign of the imaginary part negated). | |
say (1-4i).conj; # 1+4i | |
=head2 method gist | |
Defined as: | |
method gist(Complex:D:) returns Str:D | |
Usage: | |
COMPLEX.gist | |
Returns a string representation of the form "1+2i", without internal spaces. | |
(Str coercion also returns this.) | |
say (1-4i).gist; # 1-4i | |
=head2 method perl | |
Defined as: | |
method perl(Complex:D:) returns Str:D | |
Usage: | |
COMPLEX.perl | |
Returns a string representation corresponding to the unambiguous C<val()>-based | |
representation of complex literals, of the form "<1+2i>", without internal | |
spaces, and including the angles that keep the + from being treated as a | |
normal addition operator. | |
say (1-3i).perl; # <1-3i> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment