Skip to content

Commit

Permalink
Improved the polymod examples section. AlexDaniel++
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Olof Hendig committed Apr 24, 2016
1 parent 4c2ea19 commit 39e8e39
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions doc/Type/Int.pod
Expand Up @@ -74,9 +74,15 @@ of divisors, and the final result is the remainder after all the divisions.
If the number of divisors is infinite, runs until the remainder is 0.
The Int version of this method assumes all the divisors are also integers.
Coerce the invocant to Num or Rat if you wish to use fractional operations.
say 3600.polymod(60,60,24); # (0 0 1 0)
say 3661.polymod(60,60,24); # (1 1 1 0)
say 3661.polymod(60,60,24); # (1 1 1 0)
my $seconds = 3600;
say $seconds.polymod(60,60,24) Z <seconds minutes hours days>; # ((0 seconds) (0 minutes) (1 hours) (0 days))
# another way to do calculations like the ones above without using polymod
my $secs = 3661;
for 60,60,24 { say $secs mod $_; $secs div= $_ }; say $secs; # 1\n1\n1\n0\n
=head2 routine is-prime
Expand Down

0 comments on commit 39e8e39

Please sign in to comment.