Skip to content

Commit

Permalink
Initial implementation of infix:<mod>. In the long run, should maybe …
Browse files Browse the repository at this point in the history
…be in Integral (Integer?) instead of Real.
  • Loading branch information
colomon committed Jun 7, 2010
1 parent a1193fe commit 6f0d81a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Perl6/Grammar.pm
Expand Up @@ -1669,6 +1669,7 @@ token infix:sym<*> { <sym> <O('%multiplicative')> }
token infix:sym</> { <sym> <O('%multiplicative')> }
token infix:sym<div> { <sym> <O('%multiplicative')> }
token infix:sym<%> { <sym> <O('%multiplicative')> }
token infix:sym<mod> { <sym> <O('%multiplicative')> }
token infix:sym<+&> { <sym> <O('%multiplicative')> }
token infix:sym<~&> { <sym> <O('%multiplicative')> }
token infix:sym<?&> { <sym> <O('%multiplicative')> }
Expand Down
7 changes: 7 additions & 0 deletions src/core/Real.pm
Expand Up @@ -298,3 +298,10 @@ multi sub infix:<**>(Real $a, Real $b) {
multi sub infix:<**>(Num $a, Num $b) {
pir::pow__NNN($a, $b)
}

# NOTE: mod is only actually defined for integer types!
# But if you have an integer type that does Real, this
# should automatically define an appropriate mod for you.
multi sub infix:<mod>(Real $a, Real $b) {
$a - ($a div $b) * $b;
}

0 comments on commit 6f0d81a

Please sign in to comment.