diff options
author | Eduardo Julian | 2017-12-31 00:51:30 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-12-31 00:51:30 -0400 |
commit | 8f071917892ac919b91da12c2bf02d5d9b79f81a (patch) | |
tree | 8e5db500499241f6637cb1c5877314d4405390f6 /stdlib/source/lux.lux | |
parent | 59d674d660b4e52ec54ef046024b850b4eeb7a0f (diff) |
- Added bit-sets.
Diffstat (limited to 'stdlib/source/lux.lux')
-rw-r--r-- | stdlib/source/lux.lux | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index e4214a899..51e9af4dc 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -6054,3 +6054,16 @@ _ (fail "Wrong syntax for ^code"))) + +(def: #export (n/mod param subject) + (-> Nat Nat Nat) + (let [exact (|> subject (n// param) (n/* param))] + (|> subject (n/- exact)))) + +(def: #export (i/mod param subject) + (All [m] (-> Int Int Int)) + (let [raw (i/% param subject)] + (if (i/< 0 raw) + (let [shift (if (i/< 0 param) i/- i/+)] + (|> raw (shift param))) + raw))) |