Skip to content

Commit cb2d1ec

Browse files
committed
add gcd and lcm infix ops
1 parent 15b1a49 commit cb2d1ec

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

S03-operators.pod

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Synopsis 3: Perl 6 Operators
1515

1616
Created: 8 Mar 2004
1717

18-
Last Modified: 31 Mar 2011
19-
Version: 222
18+
Last Modified: 11 May 2011
19+
Version: 223
2020

2121
=head1 Overview
2222

@@ -36,7 +36,7 @@ each level:
3636
N Autoincrement ++ --
3737
R Exponentiation **
3838
L Symbolic unary ! + - ~ ? | || +^ ~^ ?^ ^
39-
L Multiplicative * / % %% +& +< +> ~& ~< ~> ?& div mod
39+
L Multiplicative * / % %% +& +< +> ~& ~< ~> ?& div mod gcd lcm
4040
L Additive + - +| +^ ~| ~^ ?| ?^
4141
L Replication x xx
4242
X Concatenation ~
@@ -879,6 +879,24 @@ C<< infix:<?&> >>, boolean and
879879
Converts both arguments to type C<Bool> and then ANDs those, returning the
880880
resulting C<Bool>.
881881

882+
=item *
883+
884+
C<< infix:<gcd> >>, greatest common divisor
885+
886+
$x gcd $y
887+
888+
Converts both arguments to an integral type and then finds the largest integer
889+
that both arguments are evenly divisible by, and returns that integer.
890+
891+
=item *
892+
893+
C<< infix:<lcm> >>, least common multiple
894+
895+
$x lcm $y
896+
897+
Converts both arguments to an integral type and then finds the smallest integer
898+
that is evenly divisible by both arguments, and returns that integer.
899+
882900
=back
883901

884902
Any bit shift operator may be turned into a rotate operator with the

0 commit comments

Comments
 (0)