Skip to content
This repository was archived by the owner on Jun 5, 2022. It is now read-only.

Commit b09b507

Browse files
committed
Merge pull request #6 from purescript/rem
Add remainder operator
2 parents 69e64af + af0cdb4 commit b09b507

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

docs/Math.md

+11
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ tan :: Radians -> Number
151151

152152
Returns the tangent of the argument.
153153

154+
#### `(%)`
155+
156+
``` purescript
157+
(%) :: Number -> Number -> Number
158+
```
159+
160+
_left-associative / precedence 7_
161+
162+
Computes the remainder after division, wrapping Javascript's `%` operator.
163+
154164
#### `e`
155165

156166
``` purescript
@@ -216,3 +226,4 @@ sqrt2 :: Number
216226
The square root of two, around 1.41421.
217227

218228

229+

src/Math.js

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ exports.pow = function (n) {
4545
};
4646
};
4747

48+
exports["%"] = function(n) {
49+
return function(m) {
50+
return n % m;
51+
};
52+
};
53+
4854
exports.round = Math.round;
4955

5056
exports.sin = Math.sin;

src/Math.purs

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ foreign import sqrt :: Number -> Number
6060
-- | Returns the tangent of the argument.
6161
foreign import tan :: Radians -> Number
6262

63+
infixl 7 %
64+
65+
-- | Computes the remainder after division, wrapping Javascript's `%` operator.
66+
foreign import (%) :: Number -> Number -> Number
67+
6368
-- | The base of natural logarithms, *e*, around 2.71828.
6469
foreign import e :: Number
6570

0 commit comments

Comments
 (0)