-
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
modBy 0 x crashes with a Debug.crash (
Line 14 in 098cca8
| var _Math_modBy = F2(function (modulus, x) { |
I suggest that there be two functions:
modBy : Int -> Int -> Maybe Intwhich returns Nothing on a zero input, and:
modByWithDefault : Int -> Int -> Int -> Int
modByWithDefault modulus default x =which does returns a default value on zero.
The reason for the second method is that there is some overhead from the Maybe handling which would be a problem in performance sensitive code, as @robinheghan pointed out on zulip. The docs should point out the performance characteristics.
I think this is a fairly easy change, but I am a bit scared of touching kernel code of course :P
robinheghan
Metadata
Metadata
Assignees
Labels
No labels