aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux.lux')
-rw-r--r--stdlib/source/lux.lux142
1 files changed, 7 insertions, 135 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index f347c281a..4f684d34d 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -2203,42 +2203,6 @@
(fail "Wrong syntax for template")}
tokens))
-(def:''' #export (r/= reference sample)
- (list [(tag$ ["lux" "doc"])
- (text$ "Rev(olution) equivalence.")])
- (-> Rev Rev Bit)
- ("lux i64 =" reference sample))
-
-(def:''' #export (r/< reference sample)
- (list [(tag$ ["lux" "doc"])
- (text$ "Rev(olution) less-than.")])
- (-> Rev Rev Bit)
- (n/< ("lux coerce" Nat reference)
- ("lux coerce" Nat sample)))
-
-(def:''' #export (r/<= reference sample)
- (list [(tag$ ["lux" "doc"])
- (text$ "Rev(olution) less-than-equal.")])
- (-> Rev Rev Bit)
- (if (n/< ("lux coerce" Nat reference)
- ("lux coerce" Nat sample))
- #1
- ("lux i64 =" reference sample)))
-
-(def:''' #export (r/> reference sample)
- (list [(tag$ ["lux" "doc"])
- (text$ "Rev(olution) greater-than.")])
- (-> Rev Rev Bit)
- (r/< sample reference))
-
-(def:''' #export (r/>= reference sample)
- (list [(tag$ ["lux" "doc"])
- (text$ "Rev(olution) greater-than-equal.")])
- (-> Rev Rev Bit)
- (if (r/< sample reference)
- #1
- ("lux i64 =" reference sample)))
-
(template [<type>
<eq-proc> <lt-proc> <eq-name> <lt-name> <lte-name> <gt-name> <gte-name>
<eq-doc> <<-doc> <<=-doc> <>-doc> <>=-doc>]
@@ -2319,110 +2283,21 @@
("lux coerce" Int (n// param subject)))]
("lux i64 -" flat subject)))
-(template [<type> <name> <op> <doc>]
+(template [<name> <op> <doc>]
[(def:''' #export (<name> param subject)
(list [(tag$ ["lux" "doc"])
(text$ <doc>)])
- (-> <type> <type> <type>)
+ (-> Int Int Int)
(<op> param subject))]
- [ Int i/+ "lux i64 +" "Int(eger) addition."]
- [ Int i/- "lux i64 -" "Int(eger) substraction."]
+ [i/+ "lux i64 +" "Int(eger) addition."]
+ [i/- "lux i64 -" "Int(eger) substraction."]
- [ Rev r/+ "lux i64 +" "Rev(olution) addition."]
- [ Rev r/- "lux i64 -" "Rev(olution) substraction."]
+ [i/* "lux i64 *" "Int(eger) multiplication."]
+ [i// "lux i64 /" "Int(eger) division."]
+ [i/% "lux i64 %" "Int(eger) remainder."]
)
-(template [<type> <name> <op> <doc>]
- [(def:''' #export (<name> param subject)
- (list [(tag$ ["lux" "doc"])
- (text$ <doc>)])
- (-> <type> <type> <type>)
- (<op> param subject))]
-
- [Int i/* "lux i64 *" "Int(eger) multiplication."]
- [Int i// "lux i64 /" "Int(eger) division."]
- [Int i/% "lux i64 %" "Int(eger) remainder."]
- )
-
-(def:''' #export (r/* param subject)
- (list [(tag$ ["lux" "doc"])
- (text$ "Rev(olution) multiplication.")])
- (-> Rev Rev Rev)
- (let' [subjectH (high-bits subject)
- subjectL (low-bits subject)
- paramH (high-bits param)
- paramL (low-bits param)
- bottom (|> subjectL
- ("lux i64 *" paramL)
- ("lux i64 logical-right-shift" 32))
- middle ("lux i64 +"
- ("lux i64 *" paramL subjectH)
- ("lux i64 *" paramH subjectL))
- top ("lux i64 *" subjectH paramH)]
- (|> bottom
- ("lux i64 +" middle)
- high-bits
- ("lux i64 +" top))))
-
-(def:''' least-significant-bit-mask (list) ($' I64 Any) 1)
-
-(def:''' (without-trailing-zeroes count remaining)
- (list)
- (-> Nat Nat (#Product Nat Nat))
- (if (|> remaining
- ("lux i64 and" least-significant-bit-mask)
- ("lux i64 =" 0))
- (without-trailing-zeroes
- ("lux i64 +" 1 count)
- ("lux i64 logical-right-shift" 1 remaining))
- [count remaining]))
-
-(def:''' #export (r// param subject)
- (list [(tag$ ["lux" "doc"])
- (text$ "Rev(olution) division.")])
- (-> Rev Rev Rev)
- (if ("lux i64 =" +0 param)
- ("lux io error" "Cannot divide Rev by zero!")
- (let' [[trailing-zeroes remaining] (without-trailing-zeroes 0 ("lux coerce" Nat param))
- [trailing-zeroes denominator] ("lux check" (#Product Nat Nat)
- (if ("lux i64 =" +0 trailing-zeroes)
- [1 ("lux i64 logical-right-shift" 1 remaining)]
- [trailing-zeroes remaining]))
- shift ("lux i64 -" trailing-zeroes 64)
- numerator ("lux i64 left-shift" shift 1)]
- (|> ("lux coerce" Int numerator)
- ("lux i64 /" ("lux coerce" Int denominator))
- ("lux i64 *" ("lux coerce" Int subject))
- ("lux coerce" Rev)))))
-
-(def:''' #export (r/% param subject)
- (list [(tag$ ["lux" "doc"])
- (text$ "Rev(olution) remainder.")])
- (-> Rev Rev Rev)
- (|> ("lux coerce" Nat subject)
- (n/% ("lux coerce" Nat param))
- ("lux coerce" Rev)))
-
-(def:''' #export (r/scale param subject)
- (list [(tag$ ["lux" "doc"])
- (text$ "Rev(olution) scale.")])
- (-> Nat Rev Rev)
- (|> ("lux coerce" Int subject)
- ("lux i64 *" ("lux coerce" Int param))
- ("lux coerce" Rev)))
-
-(def:''' #export (r/reciprocal numerator)
- (list [(tag$ ["lux" "doc"])
- (text$ "Rev(olution) reciprocal of a Nat(ural).")])
- (-> Nat Rev)
- ("lux coerce" Rev
- (let' [[trailing-zeroes remaining] (without-trailing-zeroes 0 numerator)]
- (n// remaining
- ({0 ("lux coerce" Nat -1)
- _ ("lux i64 left-shift" (n/- trailing-zeroes 64) 1)}
- trailing-zeroes)))))
-
(template [<name> <type> <test> <doc>]
[(def:''' #export (<name> left right)
(list [(tag$ ["lux" "doc"])
@@ -2437,9 +2312,6 @@
[i/min Int i/< "Int(eger) minimum."]
[i/max Int i/> "Int(eger) maximum."]
-
- [r/min Rev r/< "Rev(olution) minimum."]
- [r/max Rev r/> "Rev(olution) maximum."]
)
(def:''' (bit@encode x)