aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux')
-rw-r--r--stdlib/source/lux/concurrency/actor.lux10
-rw-r--r--stdlib/source/lux/concurrency/frp.lux2
-rw-r--r--stdlib/source/lux/concurrency/space.lux2
-rw-r--r--stdlib/source/lux/concurrency/stm.lux2
-rw-r--r--stdlib/source/lux/control/comonad.lux6
-rw-r--r--stdlib/source/lux/control/concatenative.lux96
-rw-r--r--stdlib/source/lux/control/contract.lux6
-rw-r--r--stdlib/source/lux/control/monad.lux4
-rw-r--r--stdlib/source/lux/control/parser.lux10
-rw-r--r--stdlib/source/lux/control/pipe.lux28
-rw-r--r--stdlib/source/lux/data/bit.lux4
-rw-r--r--stdlib/source/lux/data/coll/array.lux52
-rw-r--r--stdlib/source/lux/data/coll/dict.lux62
-rw-r--r--stdlib/source/lux/data/coll/list.lux44
-rw-r--r--stdlib/source/lux/data/coll/ordered/dict.lux6
-rw-r--r--stdlib/source/lux/data/coll/priority-queue.lux8
-rw-r--r--stdlib/source/lux/data/coll/queue.lux2
-rw-r--r--stdlib/source/lux/data/coll/sequence.lux68
-rw-r--r--stdlib/source/lux/data/coll/set.lux4
-rw-r--r--stdlib/source/lux/data/coll/stream.lux6
-rw-r--r--stdlib/source/lux/data/color.lux220
-rw-r--r--stdlib/source/lux/data/format/css.lux2
-rw-r--r--stdlib/source/lux/data/format/json.lux4
-rw-r--r--stdlib/source/lux/data/format/xml.lux2
-rw-r--r--stdlib/source/lux/data/ident.lux2
-rw-r--r--stdlib/source/lux/data/number.lux336
-rw-r--r--stdlib/source/lux/data/number/complex.lux180
-rw-r--r--stdlib/source/lux/data/number/ratio.lux48
-rw-r--r--stdlib/source/lux/data/text.lux6
-rw-r--r--stdlib/source/lux/data/text/lexer.lux26
-rw-r--r--stdlib/source/lux/data/text/regex.lux8
-rw-r--r--stdlib/source/lux/lang/syntax.lux64
-rw-r--r--stdlib/source/lux/lang/type.lux12
-rw-r--r--stdlib/source/lux/lang/type/check.lux20
-rw-r--r--stdlib/source/lux/macro.lux4
-rw-r--r--stdlib/source/lux/macro/poly.lux46
-rw-r--r--stdlib/source/lux/macro/poly/eq.lux2
-rw-r--r--stdlib/source/lux/macro/poly/functor.lux12
-rw-r--r--stdlib/source/lux/macro/poly/json.lux8
-rw-r--r--stdlib/source/lux/macro/syntax.lux12
-rw-r--r--stdlib/source/lux/math.lux24
-rw-r--r--stdlib/source/lux/math/logic/continuous.lux12
-rw-r--r--stdlib/source/lux/math/logic/fuzzy.lux26
-rw-r--r--stdlib/source/lux/math/random.lux104
-rw-r--r--stdlib/source/lux/test.lux24
-rw-r--r--stdlib/source/lux/time/date.lux50
-rw-r--r--stdlib/source/lux/time/duration.lux48
-rw-r--r--stdlib/source/lux/time/instant.lux128
-rw-r--r--stdlib/source/lux/type/implicit.lux14
-rw-r--r--stdlib/source/lux/type/object.lux14
-rw-r--r--stdlib/source/lux/type/unit.lux44
-rw-r--r--stdlib/source/lux/world/blob.jvm.lux72
-rw-r--r--stdlib/source/lux/world/file.lux2
53 files changed, 991 insertions, 1007 deletions
diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux
index dbe11b3a0..18bdaa61d 100644
--- a/stdlib/source/lux/concurrency/actor.lux
+++ b/stdlib/source/lux/concurrency/actor.lux
@@ -300,7 +300,7 @@
(message: #export Counter
(count! [increment Nat] state self Nat)
- (let [state' (n.+ increment state)]
+ (let [state' (n/+ increment state)]
(T;return [state' state'])))
(message: #export (Stack a)
@@ -322,12 +322,12 @@
g!actor-refs (: (List Code)
(if (list;empty? actor-vars)
(list)
- (|> actor-vars list;size n.dec
- (list;n.range +0) (list/map (|>. code;nat (~) ($) (`))))))
+ (|> actor-vars list;size n/dec
+ (list;n/range +0) (list/map (|>. code;nat (~) ($) (`))))))
ref-replacements (|> (if (list;empty? actor-vars)
(list)
- (|> actor-vars list;size n.dec
- (list;n.range +0) (list/map (|>. code;nat (~) ($) (`)))))
+ (|> actor-vars list;size n/dec
+ (list;n/range +0) (list/map (|>. code;nat (~) ($) (`)))))
(: (List Code))
(list;zip2 g!all-vars)
(: (List [Code Code])))
diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux
index ce5069b45..ba438fcf4 100644
--- a/stdlib/source/lux/concurrency/frp.lux
+++ b/stdlib/source/lux/concurrency/frp.lux
@@ -235,7 +235,7 @@
(let [(^open) &;Monad<Promise>]
(folds (function [input window]
(let [window' (L/compose window (list input))]
- (wrap (if (n.<= max (list;size window'))
+ (wrap (if (n/<= max (list;size window'))
window'
(tail window')))))
(list)
diff --git a/stdlib/source/lux/concurrency/space.lux b/stdlib/source/lux/concurrency/space.lux
index 8fe9fa583..87a1d3c22 100644
--- a/stdlib/source/lux/concurrency/space.lux
+++ b/stdlib/source/lux/concurrency/space.lux
@@ -128,7 +128,7 @@
#;Pong #;Ping)
space
self)]
- (wrap (n.inc hits)))))}
+ (wrap (n/inc hits)))))}
(with-gensyms [g!_]
(do @
[actor-name (A;resolve-actor actor-name)
diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux
index e29edc9a2..b845c3538 100644
--- a/stdlib/source/lux/concurrency/stm.lux
+++ b/stdlib/source/lux/concurrency/stm.lux
@@ -148,7 +148,7 @@
base
(#;Right key-num)
- (n.max key-num base)))
+ (n/max key-num base)))
+0
(dict;keys observers)))]
[value (dict;put label (observer label) observers)]))
diff --git a/stdlib/source/lux/control/comonad.lux b/stdlib/source/lux/control/comonad.lux
index 15625b8f1..dd395ff64 100644
--- a/stdlib/source/lux/control/comonad.lux
+++ b/stdlib/source/lux/control/comonad.lux
@@ -27,13 +27,13 @@
(macro: #export (be tokens state)
{#;doc (doc "A co-monadic parallel to the \"do\" macro."
- (let [square (function [n] (i.* n n))]
+ (let [square (function [n] (i/* n n))]
(be CoMonad<Stream>
- [inputs (iterate i.inc 2)]
+ [inputs (iterate i/inc 2)]
(square (head inputs)))))}
(case tokens
(#;Cons comonad (#;Cons [_ (#;Tuple bindings)] (#;Cons body #;Nil)))
- (if (|> bindings list;size (n.% +2) (n.= +0))
+ (if (|> bindings list;size (n/% +2) (n/= +0))
(let [g!map (: Code [_cursor (#;Symbol ["" " map "])])
g!split (: Code [_cursor (#;Symbol ["" " split "])])
body' (list/fold (: (-> [Code Code] Code Code)
diff --git a/stdlib/source/lux/control/concatenative.lux b/stdlib/source/lux/control/concatenative.lux
index b0ed0f585..ef66ffac8 100644
--- a/stdlib/source/lux/control/concatenative.lux
+++ b/stdlib/source/lux/control/concatenative.lux
@@ -1,8 +1,8 @@
(;module: [lux #- if loop when
- n.+ n.- n.* n./ n.% n.= n.< n.<= n.> n.>=
- i.+ i.- i.* i./ i.% i.= i.< i.<= i.> i.>=
- d.+ d.- d.* d./ d.% d.= d.< d.<= d.> d.>=
- f.+ f.- f.* f./ f.% f.= f.< f.<= f.> f.>=]
+ n/+ n/- n/* n// n/% n/= n/< n/<= n/> n/>=
+ i/+ i/- i/* i// i/% i/= i/< i/<= i/> i/>=
+ d/+ d/- d/* d// d/% d/= d/< d/<= d/> d/>=
+ f/+ f/- f/* f// f/% f/= f/< f/<= f/> f/>=]
(lux (control ["p" parser "p/" Monad<Parser>]
[monad])
(data [text]
@@ -121,7 +121,7 @@
(~ type)
(|>. (~@ (L/map prepare commands))))))))
-(syntax: #export (apply [arity (|> s;nat (p;filter (;n.> +0)))])
+(syntax: #export (apply [arity (|> s;nat (p;filter (;n/> +0)))])
(with-gensyms [g!func g!stack g!output]
(monad;do @
[g!inputs (|> (macro;gensym "input") (list;repeat arity) (monad;seq @))]
@@ -198,49 +198,49 @@
(function [[[stack subject] param]]
[stack (<func> param subject)]))]
- [Nat Nat n.+ ;n.+]
- [Nat Nat n.- ;n.-]
- [Nat Nat n.* ;n.*]
- [Nat Nat n./ ;n./]
- [Nat Nat n.% ;n.%]
- [Nat Bool n.= ;n.=]
- [Nat Bool n.< ;n.<]
- [Nat Bool n.<= ;n.<=]
- [Nat Bool n.> ;n.>]
- [Nat Bool n.>= ;n.>=]
-
- [Int Int i.+ ;i.+]
- [Int Int i.- ;i.-]
- [Int Int i.* ;i.*]
- [Int Int i./ ;i./]
- [Int Int i.% ;i.%]
- [Int Bool i.= ;i.=]
- [Int Bool i.< ;i.<]
- [Int Bool i.<= ;i.<=]
- [Int Bool i.> ;i.>]
- [Int Bool i.>= ;i.>=]
-
- [Deg Deg d.+ ;d.+]
- [Deg Deg d.- ;d.-]
- [Deg Deg d.* ;d.*]
- [Deg Deg d./ ;d./]
- [Deg Deg d.% ;d.%]
- [Deg Bool d.= ;d.=]
- [Deg Bool d.< ;d.<]
- [Deg Bool d.<= ;d.<=]
- [Deg Bool d.> ;d.>]
- [Deg Bool d.>= ;d.>=]
-
- [Frac Frac f.+ ;f.+]
- [Frac Frac f.- ;f.-]
- [Frac Frac f.* ;f.*]
- [Frac Frac f./ ;f./]
- [Frac Frac f.% ;f.%]
- [Frac Bool f.= ;f.=]
- [Frac Bool f.< ;f.<]
- [Frac Bool f.<= ;f.<=]
- [Frac Bool f.> ;f.>]
- [Frac Bool f.>= ;f.>=]
+ [Nat Nat n/+ ;n/+]
+ [Nat Nat n/- ;n/-]
+ [Nat Nat n/* ;n/*]
+ [Nat Nat n// ;n//]
+ [Nat Nat n/% ;n/%]
+ [Nat Bool n/= ;n/=]
+ [Nat Bool n/< ;n/<]
+ [Nat Bool n/<= ;n/<=]
+ [Nat Bool n/> ;n/>]
+ [Nat Bool n/>= ;n/>=]
+
+ [Int Int i/+ ;i/+]
+ [Int Int i/- ;i/-]
+ [Int Int i/* ;i/*]
+ [Int Int i// ;i//]
+ [Int Int i/% ;i/%]
+ [Int Bool i/= ;i/=]
+ [Int Bool i/< ;i/<]
+ [Int Bool i/<= ;i/<=]
+ [Int Bool i/> ;i/>]
+ [Int Bool i/>= ;i/>=]
+
+ [Deg Deg d/+ ;d/+]
+ [Deg Deg d/- ;d/-]
+ [Deg Deg d/* ;d/*]
+ [Deg Deg d// ;d//]
+ [Deg Deg d/% ;d/%]
+ [Deg Bool d/= ;d/=]
+ [Deg Bool d/< ;d/<]
+ [Deg Bool d/<= ;d/<=]
+ [Deg Bool d/> ;d/>]
+ [Deg Bool d/>= ;d/>=]
+
+ [Frac Frac f/+ ;f/+]
+ [Frac Frac f/- ;f/-]
+ [Frac Frac f/* ;f/*]
+ [Frac Frac f// ;f//]
+ [Frac Frac f/% ;f/%]
+ [Frac Bool f/= ;f/=]
+ [Frac Bool f/< ;f/<]
+ [Frac Bool f/<= ;f/<=]
+ [Frac Bool f/> ;f/>]
+ [Frac Bool f/>= ;f/>=]
)
(def: #export if
diff --git a/stdlib/source/lux/control/contract.lux b/stdlib/source/lux/control/contract.lux
index cc3267715..3b072caa8 100644
--- a/stdlib/source/lux/control/contract.lux
+++ b/stdlib/source/lux/control/contract.lux
@@ -16,7 +16,7 @@
{#;doc (doc "Pre-conditions."
"Given a test and an expression to run, only runs the expression if the test passes."
"Otherwise, an error is raised."
- (pre (i.= 4 (i.+ 2 2))
+ (pre (i/= 4 (i/+ 2 2))
(foo 123 456 789)))}
(wrap (list (` (exec (assert! (~ (code;text (format "Pre-condition failed: " (%code test))))
(~ test))
@@ -27,8 +27,8 @@
"Given a predicate and an expression to run, evaluates the expression and then tests the output with the predicate."
"If the predicate returns true, returns the value of the expression."
"Otherwise, an error is raised."
- (post i.even?
- (i.+ 2 2)))}
+ (post i/even?
+ (i/+ 2 2)))}
(do @
[g!output (macro;gensym "")]
(wrap (list (` (let [(~ g!output) (~ expr)]
diff --git a/stdlib/source/lux/control/monad.lux b/stdlib/source/lux/control/monad.lux
index fb900d3e7..e4495cc92 100644
--- a/stdlib/source/lux/control/monad.lux
+++ b/stdlib/source/lux/control/monad.lux
@@ -23,7 +23,7 @@
counter
(#;Cons _ xs')
- (recur (n.inc counter) xs'))))
+ (recur (n/inc counter) xs'))))
(def: (reverse xs)
(All [a]
@@ -60,7 +60,7 @@
(wrap (f3 z))))}
(case tokens
(#;Cons monad (#;Cons [_ (#;Tuple bindings)] (#;Cons body #;Nil)))
- (if (|> bindings list/size (n.% +2) (n.= +0))
+ (if (|> bindings list/size (n/% +2) (n/= +0))
(let [g!map (: Code [_cursor (#;Symbol ["" " map "])])
g!join (: Code [_cursor (#;Symbol ["" " join "])])
g!apply (: Code [_cursor (#;Symbol ["" " apply "])])
diff --git a/stdlib/source/lux/control/parser.lux b/stdlib/source/lux/control/parser.lux
index 1b91a0248..095104f09 100644
--- a/stdlib/source/lux/control/parser.lux
+++ b/stdlib/source/lux/control/parser.lux
@@ -136,10 +136,10 @@
(def: #export (exactly n p)
{#;doc "Parse exactly N times."}
(All [s a] (-> Nat (Parser s a) (Parser s (List a))))
- (if (n.> +0 n)
+ (if (n/> +0 n)
(do Monad<Parser>
[x p
- xs (exactly (n.dec n) p)]
+ xs (exactly (n/dec n) p)]
(wrap (#;Cons x xs)))
(:: Monad<Parser> wrap (list))))
@@ -154,7 +154,7 @@
(def: #export (at-most n p)
{#;doc "Parse at most N times."}
(All [s a] (-> Nat (Parser s a) (Parser s (List a))))
- (if (n.> +0 n)
+ (if (n/> +0 n)
(function [input]
(case (p input)
(#e;Error msg)
@@ -163,7 +163,7 @@
(#e;Success [input' x])
(run input'
(do Monad<Parser>
- [xs (at-most (n.dec n) p)]
+ [xs (at-most (n/dec n) p)]
(wrap (#;Cons x xs))))
))
(:: Monad<Parser> wrap (list))))
@@ -173,7 +173,7 @@
(All [s a] (-> Nat Nat (Parser s a) (Parser s (List a))))
(do Monad<Parser>
[min-xs (exactly from p)
- max-xs (at-most (n.- from to) p)]
+ max-xs (at-most (n/- from to) p)]
(wrap (:: list;Monad<List> join (list min-xs max-xs)))))
(def: #export (sep-by sep p)
diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux
index 6eb8e8156..9903986f7 100644
--- a/stdlib/source/lux/control/pipe.lux
+++ b/stdlib/source/lux/control/pipe.lux
@@ -16,9 +16,9 @@
(syntax: #export (new> [tokens (p;at-least +2 s;any)])
{#;doc (doc "Ignores the piped argument, and begins a new pipe."
(|> 20
- (i.* 3)
- (i.+ 4)
- (new> 0 i.inc)))}
+ (i/* 3)
+ (i/+ 4)
+ (new> 0 i/inc)))}
(case (list;reverse tokens)
(^ (list& _ r-body))
(wrap (list (` (|> (~@ (list;reverse r-body))))))
@@ -29,7 +29,7 @@
(syntax: #export (let> binding body prev)
{#;doc (doc "Gives a name to the piped-argument, within the given expression."
(|> 5
- (let> X (i.+ X X))))}
+ (let> X (i/+ X X))))}
(wrap (list (` (let [(~ binding) (~ prev)]
(~ body))))))
@@ -40,8 +40,8 @@
"Both the tests and the bodies are piped-code, and must be given inside a tuple."
"If a last else-pipe is not given, the piped-argument will be used instead."
(|> 5
- (cond> [i.even?] [(i.* 2)]
- [i.odd?] [(i.* 3)]
+ (cond> [i/even?] [(i/* 2)]
+ [i/odd?] [(i/* 3)]
[(new> -1)])))}
(with-gensyms [g!temp]
(wrap (list (` (with-expansions
@@ -61,8 +61,8 @@
{#;doc (doc "Loops for pipes."
"Both the testing and calculating steps are pipes and must be given inside tuples."
(|> 1
- (loop> [(i.< 10)]
- [i.inc])))}
+ (loop> [(i/< 10)]
+ [i/inc])))}
(with-gensyms [g!temp]
(wrap (list (` (loop [(~ g!temp) (~ prev)]
(if (|> (~ g!temp) (~@ test))
@@ -74,9 +74,9 @@
"Each steps in the monadic computation is a pipe and must be given inside a tuple."
(|> 5
(do> Monad<Identity>
- [(i.* 3)]
- [(i.+ 4)]
- [i.inc])))}
+ [(i/* 3)]
+ [(i/+ 4)]
+ [i/inc])))}
(with-gensyms [g!temp]
(case (list;reverse steps)
(^ (list& last-step prev-steps))
@@ -96,7 +96,7 @@
"Will generate piped computations, but their results will not be used in the larger scope."
(|> 5
(exec> [int-to-nat %n log!])
- (i.* 10)))}
+ (i/* 10)))}
(do @
[g!temp (macro;gensym "")]
(wrap (list (` (let [(~ g!temp) (~ prev)]
@@ -107,8 +107,8 @@
{#;doc (doc "Parallel branching for pipes."
"Allows to run multiple pipelines for a value and gives you a tuple of the outputs."
(|> 5
- (tuple> [(i.* 10)]
- [i.dec (i./ 2)]
+ (tuple> [(i/* 10)]
+ [i/dec (i// 2)]
[Int/encode]))
"Will become: [50 2 \"5\"]")}
(do @
diff --git a/stdlib/source/lux/data/bit.lux b/stdlib/source/lux/data/bit.lux
index ee4dc4449..b0b31d2dd 100644
--- a/stdlib/source/lux/data/bit.lux
+++ b/stdlib/source/lux/data/bit.lux
@@ -46,13 +46,13 @@
(def: #export (set? idx input)
(-> Nat Nat Bool)
- (|> input (;;and (shift-left idx +1)) (n.= +0) ;not))
+ (|> input (;;and (shift-left idx +1)) (n/= +0) ;not))
(do-template [<name> <main> <comp>]
[(def: #export (<name> distance input)
(-> Nat Nat Nat)
(;;or (<main> distance input)
- (<comp> (n.- (n.% width distance)
+ (<comp> (n/- (n/% width distance)
width)
input)))]
diff --git a/stdlib/source/lux/data/coll/array.lux b/stdlib/source/lux/data/coll/array.lux
index c697e5681..1eeb1342c 100644
--- a/stdlib/source/lux/data/coll/array.lux
+++ b/stdlib/source/lux/data/coll/array.lux
@@ -34,17 +34,17 @@
(def: #export (copy length src-start src-array dest-start dest-array)
(All [a] (-> Nat Nat (Array a) Nat (Array a)
(Array a)))
- (if (n.= +0 length)
+ (if (n/= +0 length)
dest-array
(list/fold (function [offset target]
- (case (read (n.+ offset src-start) src-array)
+ (case (read (n/+ offset src-start) src-array)
#;None
target
(#;Some value)
- (write (n.+ offset dest-start) value target)))
+ (write (n/+ offset dest-start) value target)))
dest-array
- (list;n.range +0 (n.dec length)))))
+ (list;n/range +0 (n/dec length)))))
(def: #export (occupied array)
{#;doc "Finds out how many cells in an array are occupied."}
@@ -55,14 +55,14 @@
count
(#;Some _)
- (n.inc count)))
+ (n/inc count)))
+0
(list;indices (size array))))
(def: #export (vacant array)
{#;doc "Finds out how many cells in an array are vacant."}
(All [a] (-> (Array a) Nat))
- (n.- (occupied array) (size array)))
+ (n/- (occupied array) (size array)))
(def: #export (filter p xs)
(All [a]
@@ -97,15 +97,15 @@
(-> (-> a Bool) (Array a) (Maybe a)))
(let [arr-size (size xs)]
(loop [idx +0]
- (if (n.< arr-size idx)
+ (if (n/< arr-size idx)
(case (read idx xs)
#;None
- (recur (n.inc idx))
+ (recur (n/inc idx))
(#;Some x)
(if (p x)
(#;Some x)
- (recur (n.inc idx))))
+ (recur (n/inc idx))))
#;None))))
(def: #export (find+ p xs)
@@ -114,15 +114,15 @@
(-> (-> Nat a Bool) (Array a) (Maybe [Nat a])))
(let [arr-size (size xs)]
(loop [idx +0]
- (if (n.< arr-size idx)
+ (if (n/< arr-size idx)
(case (read idx xs)
#;None
- (recur (n.inc idx))
+ (recur (n/inc idx))
(#;Some x)
(if (p idx x)
(#;Some [idx x])
- (recur (n.inc idx))))
+ (recur (n/inc idx))))
#;None))))
(def: #export (clone xs)
@@ -141,19 +141,19 @@
(def: #export (from-list xs)
(All [a] (-> (List a) (Array a)))
(product;right (list/fold (function [x [idx arr]]
- [(n.inc idx) (write idx x arr)])
+ [(n/inc idx) (write idx x arr)])
[+0 (new (list;size xs))]
xs)))
-(def: underflow Nat (n.dec +0))
+(def: underflow Nat (n/dec +0))
(def: #export (to-list array)
(All [a] (-> (Array a) (List a)))
- (loop [idx (n.dec (size array))
+ (loop [idx (n/dec (size array))
output #;Nil]
- (if (n.= underflow idx)
+ (if (n/= underflow idx)
output
- (recur (n.dec idx)
+ (recur (n/dec idx)
(case (read idx array)
(#;Some head)
(#;Cons head output)
@@ -166,7 +166,7 @@
(def: (= xs ys)
(let [sxs (size xs)
sxy (size ys)]
- (and (n.= sxy sxs)
+ (and (n/= sxy sxs)
(list/fold (function [idx prev]
(and prev
(case [(read idx xs) (read idx ys)]
@@ -179,7 +179,7 @@
_
false)))
true
- (list;n.range +0 (n.dec sxs)))))
+ (list;n/range +0 (n/dec sxs)))))
))
(struct: #export Monoid<Array> (All [a]
@@ -189,14 +189,14 @@
(def: (compose xs ys)
(let [sxs (size xs)
sxy (size ys)]
- (|> (new (n.+ sxy sxs))
+ (|> (new (n/+ sxy sxs))
(copy sxs +0 xs +0)
(copy sxy +0 ys sxs)))))
(struct: #export _ (Functor Array)
(def: (map f ma)
(let [arr-size (size ma)]
- (if (n.= +0 arr-size)
+ (if (n/= +0 arr-size)
(new arr-size)
(list/fold (: (-> Nat (Array ($ +1)) (Array ($ +1)))
(function [idx mb]
@@ -207,7 +207,7 @@
(#;Some x)
(write idx (f x) mb))))
(new arr-size)
- (list;n.range +0 (n.dec arr-size)))
+ (list;n/range +0 (n/dec arr-size)))
## (list/fold (function [idx mb]
## (case (read idx ma)
## #;None
@@ -216,7 +216,7 @@
## (#;Some x)
## (write idx (f x) mb)))
## (new arr-size)
- ## (list;n.range +0 (n.dec arr-size)))
+ ## (list;n/range +0 (n/dec arr-size)))
))))
(struct: #export _ (Fold Array)
@@ -224,11 +224,11 @@
(let [arr-size (size xs)]
(loop [so-far init
idx +0]
- (if (n.< arr-size idx)
+ (if (n/< arr-size idx)
(case (read idx xs)
#;None
- (recur so-far (n.inc idx))
+ (recur so-far (n/inc idx))
(#;Some value)
- (recur (f value so-far) (n.inc idx)))
+ (recur (f value so-far) (n/inc idx)))
so-far)))))
diff --git a/stdlib/source/lux/data/coll/dict.lux b/stdlib/source/lux/data/coll/dict.lux
index cee6a83fc..0273dc852 100644
--- a/stdlib/source/lux/data/coll/dict.lux
+++ b/stdlib/source/lux/data/coll/dict.lux
@@ -97,13 +97,13 @@
## which is 1/4 of the branching factor (or a left-shift 2).
(def: demotion-threshold
Nat
- (bit;shift-left (n.- +2 branching-exponent) +1))
+ (bit;shift-left (n/- +2 branching-exponent) +1))
## The threshold on which #Base nodes are promoted to #Hierarchy nodes,
## which is 1/2 of the branching factor (or a left-shift 1).
(def: promotion-threshold
Nat
- (bit;shift-left (n.- +1 branching-exponent) +1))
+ (bit;shift-left (n/- +1 branching-exponent) +1))
## The size of hierarchy-nodes, which is 2^(branching-exponent).
(def: hierarchy-nodes-size
@@ -120,12 +120,12 @@
(def: (insert! idx value old-array)
(All [a] (-> Index a (Array a) (Array a)))
(let [old-size (array;size old-array)]
- (|> ## (array;new (n.inc old-size))
+ (|> ## (array;new (n/inc old-size))
(: (Array ($ +0))
- (array;new (n.inc old-size)))
+ (array;new (n/inc old-size)))
(array;copy idx +0 old-array +0)
(array;write idx value)
- (array;copy (n.- idx old-size) idx old-array (n.inc idx)))))
+ (array;copy (n/- idx old-size) idx old-array (n/inc idx)))))
## Creates a copy of an array with an index set to a particular value.
(def: (update! idx value array)
@@ -140,23 +140,23 @@
## Shrinks a copy of the array by removing the space at index.
(def: (remove! idx array)
(All [a] (-> Index (Array a) (Array a)))
- (let [new-size (n.dec (array;size array))]
+ (let [new-size (n/dec (array;size array))]
(|> (array;new new-size)
(array;copy idx +0 array +0)
- (array;copy (n.- idx new-size) (n.inc idx) array idx))))
+ (array;copy (n/- idx new-size) (n/inc idx) array idx))))
## Given a top-limit for indices, produces all indices in [0, R).
(def: indices-for
(-> Nat (List Index))
- (|>. n.dec (list;n.range +0)))
+ (|>. n/dec (list;n/range +0)))
## Increases the level-shift by the branching-exponent, to explore
## levels further down the tree.
(def: level-up
(-> Level Level)
- (n.+ branching-exponent))
+ (n/+ branching-exponent))
-(def: hierarchy-mask BitMap (n.dec hierarchy-nodes-size))
+(def: hierarchy-mask BitMap (n/dec hierarchy-nodes-size))
## Gets the branching-factor sized section of the hash corresponding
## to a particular level, and uses that as an index into the array.
@@ -177,12 +177,12 @@
(def: (bit-position-is-set? bit bitmap)
(-> BitPosition BitMap Bool)
- (not (n.= clean-bitmap (bit;and bit bitmap))))
+ (not (n/= clean-bitmap (bit;and bit bitmap))))
## Figures out whether a bitmap only contains a single bit-position.
(def: only-bit-position?
(-> BitPosition BitMap Bool)
- n.=)
+ n/=)
(def: (set-bit-position bit bitmap)
(-> BitPosition BitMap BitMap)
@@ -203,7 +203,7 @@
## associated with it.
(def: bit-position-mask
(-> BitPosition BitMap)
- n.dec)
+ n/dec)
## The index on the base array, based on it's bit-position.
(def: (base-index bit-position bitmap)
@@ -227,16 +227,16 @@
(let [[bitmap base] node]
(case (array;read idx h-array)
#;None [insertion-idx node]
- (#;Some sub-node) (if (n.= except-idx idx)
+ (#;Some sub-node) (if (n/= except-idx idx)
[insertion-idx node]
- [(n.inc insertion-idx)
+ [(n/inc insertion-idx)
[(set-bit-position (->bit-position idx) bitmap)
(array;write insertion-idx (#;Left sub-node) base)]])
)))
[+0 [clean-bitmap
- ## (array;new (n.dec h-size))
+ ## (array;new (n/dec h-size))
(: (Base ($ +0) ($ +1))
- (array;new (n.dec h-size)))
+ (array;new (n/dec h-size)))
]]
(list;indices (array;size h-array)))))
@@ -253,7 +253,7 @@
(product;right (list/fold (function [hierarchy-idx (^@ default [base-idx h-array])]
(if (bit-position-is-set? (->bit-position hierarchy-idx)
bitmap)
- [(n.inc base-idx)
+ [(n/inc base-idx)
(case (array;read base-idx base)
(#;Some (#;Left sub-node))
(array;write hierarchy-idx sub-node h-array)
@@ -297,14 +297,14 @@
## [_size sub-node]
## _
- ## [(n.inc _size) empty])
+ ## [(n/inc _size) empty])
[_size' sub-node] (: [Nat (Node ($ +0) ($ +1))]
(case (array;read idx hierarchy)
(#;Some sub-node)
[_size sub-node]
_
- [(n.inc _size) empty]))
+ [(n/inc _size) empty]))
]
(#Hierarchy _size'
(update! idx (put' (level-up level) hash key val Hash<k> sub-node)
@@ -334,7 +334,7 @@
## Otherwise, I compare the hashes of the keys.
(#Base bitmap (update! idx
(#;Left (let [hash' (:: Hash<k> hash key')]
- (if (n.= hash hash')
+ (if (n/= hash hash')
## If the hashes are
## the same, a new
## #Collisions node
@@ -357,10 +357,10 @@
## However, if the BitPosition has not been used yet, I check
## whether this #Base node is ready for a promotion.
(let [base-count (bitmap-size bitmap)]
- (if (n.>= promotion-threshold base-count)
+ (if (n/>= promotion-threshold base-count)
## If so, I promote it to a #Hierarchy node, and add the new
## KV-pair as a singleton node to it.
- (#Hierarchy (n.inc base-count)
+ (#Hierarchy (n/inc base-count)
(|> (promote-base put' Hash<k> level bitmap base)
(array;write (level-index level hash)
(put' (level-up level) hash key val Hash<k> empty))))
@@ -371,7 +371,7 @@
## For #Collisions nodes, I compare the hashes.
(#Collisions _hash _colls)
- (if (n.= hash _hash)
+ (if (n/= hash _hash)
## If they're equal, that means the new KV contributes to the
## collisions.
(case (collision-index Hash<k> key _colls)
@@ -415,11 +415,11 @@
## But if the sub-removal yielded an empty sub-node...
(if (empty?' sub-node')
## Check if it's due time for a demotion.
- (if (n.<= demotion-threshold h-size)
+ (if (n/<= demotion-threshold h-size)
## If so, perform it.
(#Base (demote-hierarchy idx [h-size h-array]))
## Otherwise, just clear the space.
- (#Hierarchy (n.dec h-size) (vacant! idx h-array)))
+ (#Hierarchy (n/dec h-size) (vacant! idx h-array)))
## But if the sub-removal yielded a non-empty node, then
## just update the hiearchy branch.
(#Hierarchy h-size (update! idx sub-node' h-array)))))))
@@ -477,7 +477,7 @@
## But if so, then check the size of the collisions list.
(#;Some idx)
- (if (n.= +1 (array;size _colls))
+ (if (n/= +1 (array;size _colls))
## If there's only one left, then removing it leaves us with
## an empty node.
empty
@@ -522,10 +522,10 @@
(All [k v] (-> (Node k v) Nat))
(case node
(#Hierarchy _size hierarchy)
- (array/fold n.+ +0 (array/map size' hierarchy))
+ (array/fold n/+ +0 (array/map size' hierarchy))
(#Base _ base)
- (array/fold n.+ +0 (array/map (function [sub-node']
+ (array/fold n/+ +0 (array/map (function [sub-node']
(case sub-node'
(#;Left sub-node) (size' sub-node)
(#;Right _) +1))
@@ -614,7 +614,7 @@
(def: #export empty?
(All [k v] (-> (Dict k v) Bool))
- (|>. size (n.= +0)))
+ (|>. size (n/= +0)))
(def: #export (entries dict)
(All [k v] (-> (Dict k v) (List [k v])))
@@ -685,7 +685,7 @@
## [Structures]
(struct: #export (Eq<Dict> Eq<v>) (All [k v] (-> (Eq v) (Eq (Dict k v))))
(def: (= test subject)
- (and (n.= (size test)
+ (and (n/= (size test)
(size subject))
(list;every? (function [k]
(case [(get k test) (get k subject)]
diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux
index d7bbe0161..d00428478 100644
--- a/stdlib/source/lux/data/coll/list.lux
+++ b/stdlib/source/lux/data/coll/list.lux
@@ -67,7 +67,7 @@
[(def: #export (<name> n xs)
(All [a]
(-> Nat (List a) (List a)))
- (if (n.> +0 n)
+ (if (n/> +0 n)
(case xs
#;Nil
#;Nil
@@ -76,8 +76,8 @@
<then>)
<else>))]
- [take (#;Cons [x (take (n.dec n) xs')]) #;Nil]
- [drop (drop (n.dec n) xs') xs]
+ [take (#;Cons [x (take (n/dec n) xs')]) #;Nil]
+ [drop (drop (n/dec n) xs') xs]
)
(do-template [<name> <then> <else>]
@@ -100,13 +100,13 @@
(def: #export (split n xs)
(All [a]
(-> Nat (List a) [(List a) (List a)]))
- (if (n.> +0 n)
+ (if (n/> +0 n)
(case xs
#;Nil
[#;Nil #;Nil]
(#;Cons [x xs'])
- (let [[tail rest] (split (n.dec n) xs')]
+ (let [[tail rest] (split (n/dec n) xs')]
[(#;Cons [x tail]) rest]))
[#;Nil xs]))
@@ -144,8 +144,8 @@
{#;doc "A list of the value x, repeated n times."}
(All [a]
(-> Nat a (List a)))
- (if (n.> +0 n)
- (#;Cons [x (repeat (n.dec n) x)])
+ (if (n/> +0 n)
+ (#;Cons [x (repeat (n/dec n) x)])
#;Nil))
(def: (iterate' f x)
@@ -198,7 +198,7 @@
(def: #export (size list)
(All [a] (-> (List a) Nat))
- (fold (function [_ acc] (n.+ +1 acc)) +0 list))
+ (fold (function [_ acc] (n/+ +1 acc)) +0 list))
(do-template [<name> <init> <op>]
[(def: #export (<name> p xs)
@@ -230,9 +230,9 @@
#;None
(#;Cons [x xs'])
- (if (n.= +0 i)
+ (if (n/= +0 i)
(#;Some x)
- (nth (n.dec i) xs'))))
+ (nth (n/dec i) xs'))))
## [Structures]
(struct: #export (Eq<List> Eq<a>)
@@ -311,8 +311,8 @@
(list& from (<name> (<inc> from) to))
(list)))]
- [i.range Int i.<= i.inc]
- [n.range Nat n.<= n.inc]
+ [i/range Int i/<= i/inc]
+ [n/range Nat n/<= n/inc]
)
(def: #export (empty? xs)
@@ -355,16 +355,16 @@
((zip +3) xs ys zs))}
(case tokens
(^ (list [_ (#;Nat num-lists)]))
- (if (n.> +0 num-lists)
+ (if (n/> +0 num-lists)
(let [(^open) Functor<List>
- indices (n.range +0 (n.dec num-lists))
+ indices (n/range +0 (n/dec num-lists))
type-vars (: (List Code) (map (. symbol$ Nat/encode) indices))
zip-type (` (All [(~@ type-vars)]
(-> (~@ (map (: (-> Code Code) (function [var] (` (List (~ var)))))
type-vars))
(List [(~@ type-vars)]))))
vars+lists (|> indices
- (map n.inc)
+ (map n/inc)
(map (function [idx]
(let [base (Nat/encode idx)]
[(symbol$ base)
@@ -396,12 +396,12 @@
{#;doc (doc "Create list zippers with the specified number of input lists."
(def: #export zip2-with (zip-with +2))
(def: #export zip3-with (zip-with +3))
- ((zip-with +2) i.+ xs ys))}
+ ((zip-with +2) i/+ xs ys))}
(case tokens
(^ (list [_ (#;Nat num-lists)]))
- (if (n.> +0 num-lists)
+ (if (n/> +0 num-lists)
(let [(^open) Functor<List>
- indices (n.range +0 (n.dec num-lists))
+ indices (n/range +0 (n/dec num-lists))
g!return-type (symbol$ "\treturn-type\t")
g!func (symbol$ "\tfunc\t")
type-vars (: (List Code) (map (. symbol$ Nat/encode) indices))
@@ -411,7 +411,7 @@
type-vars))
(List (~ g!return-type)))))
vars+lists (|> indices
- (map n.inc)
+ (map n/inc)
(map (function [idx]
(let [base (Nat/encode idx)]
[(symbol$ base)
@@ -499,7 +499,7 @@
#;Nil
(#;Cons x xs')
- (#;Cons [idx x] (enumerate' (n.inc idx) xs'))))
+ (#;Cons [idx x] (enumerate' (n/inc idx) xs'))))
(def: #export (enumerate xs)
{#;doc "Pairs every element in the list with it's index, starting at 0."}
@@ -509,6 +509,6 @@
(def: #export (indices size)
{#;doc "Produces all the valid indices for a given size."}
(All [a] (-> Nat (List Nat)))
- (if (n.= +0 size)
+ (if (n/= +0 size)
(list)
- (|> size n.dec (n.range +0))))
+ (|> size n/dec (n/range +0))))
diff --git a/stdlib/source/lux/data/coll/ordered/dict.lux b/stdlib/source/lux/data/coll/ordered/dict.lux
index 24b6b7c3b..ecf661b15 100644
--- a/stdlib/source/lux/data/coll/ordered/dict.lux
+++ b/stdlib/source/lux/data/coll/ordered/dict.lux
@@ -115,11 +115,11 @@
+0
(#;Some node)
- (n.inc (<op> (recur (get@ #left node))
+ (n/inc (<op> (recur (get@ #left node))
(recur (get@ #right node)))))))]
- [size n.+]
- [depth n.max]
+ [size n/+]
+ [depth n/max]
)
(do-template [<name> <other-color> <self-color> <no-change>]
diff --git a/stdlib/source/lux/data/coll/priority-queue.lux b/stdlib/source/lux/data/coll/priority-queue.lux
index 96ad71a6b..5e270518d 100644
--- a/stdlib/source/lux/data/coll/priority-queue.lux
+++ b/stdlib/source/lux/data/coll/priority-queue.lux
@@ -22,7 +22,7 @@
(All [a] (-> (Queue a) (Maybe a)))
(do maybe;Monad<Maybe>
[fingers queue]
- (wrap (maybe;assume (F;search (n.= (F;tag fingers)) fingers)))))
+ (wrap (maybe;assume (F;search (n/= (F;tag fingers)) fingers)))))
(def: #export (size queue)
(All [a] (-> (Queue a) Nat))
@@ -37,7 +37,7 @@
+1
(#F;Branch _ left right)
- (n.+ (recur left) (recur right))))))
+ (n/+ (recur left) (recur right))))))
(def: #export (member? Eq<a> queue member)
(All [a] (-> (Eq a) (Queue a) a Bool))
@@ -63,12 +63,12 @@
node' (loop [node (get@ #F;tree fingers)]
(case node
(#F;Leaf priority reference)
- (if (n.= highest-priority priority)
+ (if (n/= highest-priority priority)
#;None
(#;Some node))
(#F;Branch priority left right)
- (if (n.= highest-priority (F;tag (set@ #F;tree left fingers)))
+ (if (n/= highest-priority (F;tag (set@ #F;tree left fingers)))
(case (recur left)
#;None
(#;Some right)
diff --git a/stdlib/source/lux/data/coll/queue.lux b/stdlib/source/lux/data/coll/queue.lux
index b6e5a7161..dd26ccc32 100644
--- a/stdlib/source/lux/data/coll/queue.lux
+++ b/stdlib/source/lux/data/coll/queue.lux
@@ -30,7 +30,7 @@
(def: #export (size queue)
(All [a] (-> (Queue a) Nat))
(let [(^slots [#front #rear]) queue]
- (n.+ (list;size front)
+ (n/+ (list;size front)
(list;size rear))))
(def: #export empty?
diff --git a/stdlib/source/lux/data/coll/sequence.lux b/stdlib/source/lux/data/coll/sequence.lux
index f76c824a7..d8c3ddfb9 100644
--- a/stdlib/source/lux/data/coll/sequence.lux
+++ b/stdlib/source/lux/data/coll/sequence.lux
@@ -42,8 +42,8 @@
(-> Level Level)
(<op> branching-exponent))]
- [level-up n.+]
- [level-down n.-]
+ [level-up n/+]
+ [level-down n/-]
)
(def: full-node-size
@@ -52,7 +52,7 @@
(def: branch-idx-mask
Nat
- (n.dec full-node-size))
+ (n/dec full-node-size))
(def: branch-idx
(-> Index Index)
@@ -64,15 +64,15 @@
(def: (tail-off vec-size)
(-> Nat Nat)
- (if (n.< full-node-size vec-size)
+ (if (n/< full-node-size vec-size)
+0
- (|> (n.dec vec-size)
+ (|> (n/dec vec-size)
(bit;shift-right branching-exponent)
(bit;shift-left branching-exponent))))
(def: (new-path level tail)
(All [a] (-> Level (Base a) (Node a)))
- (if (n.= +0 level)
+ (if (n/= +0 level)
(#Base tail)
(|> ## (new-hierarchy [])
(: (Hierarchy ($ +0))
@@ -89,9 +89,9 @@
(def: (push-tail size level tail parent)
(All [a] (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a)))
- (let [sub-idx (branch-idx (bit;shift-right level (n.dec size)))
+ (let [sub-idx (branch-idx (bit;shift-right level (n/dec size)))
## If we're currently on a bottom node
- sub-node (if (n.= branching-exponent level)
+ sub-node (if (n/= branching-exponent level)
## Just add the tail to it
(#Base tail)
## Otherwise, check whether there's a vacant spot
@@ -112,9 +112,9 @@
(def: (expand-tail val tail)
(All [a] (-> a (Base a) (Base a)))
(let [tail-size (array;size tail)]
- (|> ## (array;new (n.inc tail-size))
+ (|> ## (array;new (n/inc tail-size))
(: (Base ($ +0))
- (array;new (n.inc tail-size)))
+ (array;new (n/inc tail-size)))
(array;copy tail-size +0 tail +0)
(array;write tail-size val)
)))
@@ -128,7 +128,7 @@
(array;write sub-idx (#Hierarchy (put' (level-down level) idx val sub-node))))
(^multi (#;Some (#Base base))
- (n.= +0 (level-down level)))
+ (n/= +0 (level-down level)))
(|> (array;clone hierarchy)
(array;write sub-idx (|> (array;clone base)
(array;write (branch-idx idx) val)
@@ -139,11 +139,11 @@
(def: (pop-tail size level hierarchy)
(All [a] (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a))))
- (let [sub-idx (branch-idx (bit;shift-right level (n.- +2 size)))]
- (cond (n.= +0 sub-idx)
+ (let [sub-idx (branch-idx (bit;shift-right level (n/- +2 size)))]
+ (cond (n/= +0 sub-idx)
#;None
- (n.> branching-exponent level)
+ (n/> branching-exponent level)
(do maybe;Monad<Maybe>
[base|hierarchy (array;read sub-idx hierarchy)
sub (case base|hierarchy
@@ -198,15 +198,15 @@
(All [a] (-> a (Sequence a) (Sequence a)))
## Check if there is room in the tail.
(let [vec-size (get@ #size vec)]
- (if (|> vec-size (n.- (tail-off vec-size)) (n.< full-node-size))
+ (if (|> vec-size (n/- (tail-off vec-size)) (n/< full-node-size))
## If so, append to it.
(|> vec
- (update@ #size n.inc)
+ (update@ #size n/inc)
(update@ #tail (expand-tail val)))
## Otherwise, push tail into the tree
## --------------------------------------------------------
## Will the root experience an overflow with this addition?
- (|> (if (n.> (bit;shift-left (get@ #level vec) +1)
+ (|> (if (n/> (bit;shift-left (get@ #level vec) +1)
(bit;shift-right branching-exponent vec-size))
## If so, a brand-new root must be established, that is
## 1-level taller.
@@ -222,20 +222,20 @@
(update@ #root (push-tail vec-size (get@ #level vec) (get@ #tail vec)))))
## Finally, update the size of the Sequence and grow a new
## tail with the new element as it's sole member.
- (update@ #size n.inc)
+ (update@ #size n/inc)
(set@ #tail (new-tail val)))
)))
(def: (base-for idx vec)
(All [a] (-> Index (Sequence a) (Maybe (Base a))))
(let [vec-size (get@ #size vec)]
- (if (and (n.>= +0 idx)
- (n.< vec-size idx))
- (if (n.>= (tail-off vec-size) idx)
+ (if (and (n/>= +0 idx)
+ (n/< vec-size idx))
+ (if (n/>= (tail-off vec-size) idx)
(#;Some (get@ #tail vec))
(loop [level (get@ #level vec)
hierarchy (get@ #root vec)]
- (case [(n.> branching-exponent level)
+ (case [(n/> branching-exponent level)
(array;read (branch-idx (bit;shift-right level idx)) hierarchy)]
[true (#;Some (#Hierarchy sub))]
(recur (level-down level) sub)
@@ -259,9 +259,9 @@
(def: #export (put idx val vec)
(All [a] (-> Nat a (Sequence a) (Sequence a)))
(let [vec-size (get@ #size vec)]
- (if (and (n.>= +0 idx)
- (n.< vec-size idx))
- (if (n.>= (tail-off vec-size) idx)
+ (if (and (n/>= +0 idx)
+ (n/< vec-size idx))
+ (if (n/>= (tail-off vec-size) idx)
(|> vec
## (update@ #tail (|>. array;clone (array;write (branch-idx idx) val)))
(update@ #tail (: (-> (Base ($ +0)) (Base ($ +0)))
@@ -290,16 +290,16 @@
empty
vec-size
- (if (|> vec-size (n.- (tail-off vec-size)) (n.> +1))
+ (if (|> vec-size (n/- (tail-off vec-size)) (n/> +1))
(let [old-tail (get@ #tail vec)
- new-tail-size (n.dec (array;size old-tail))]
+ new-tail-size (n/dec (array;size old-tail))]
(|> vec
- (update@ #size n.dec)
+ (update@ #size n/dec)
(set@ #tail (|> (array;new new-tail-size)
(array;copy new-tail-size +0 old-tail +0)))))
(maybe;assume
(do maybe;Monad<Maybe>
- [new-tail (base-for (n.- +2 vec-size) vec)
+ [new-tail (base-for (n/- +2 vec-size) vec)
#let [## [level' root'] (let [init-level (get@ #level vec)]
## (loop [level init-level
## root (maybe;default (new-hierarchy [])
@@ -308,7 +308,7 @@
## ## (maybe;default (new-hierarchy [])
## ## (pop-tail vec-size init-level (get@ #root vec))))
## ]
- ## (if (n.> branching-exponent level)
+ ## (if (n/> branching-exponent level)
## (case [(array;read +1 root) (array;read +0 root)]
## [#;None (#;Some (#Hierarchy sub-node))]
## (recur (level-down level) sub-node)
@@ -325,7 +325,7 @@
root (: (Hierarchy ($ +0))
(maybe;default (new-hierarchy [])
(pop-tail vec-size init-level (get@ #root vec))))]
- (if (n.> branching-exponent level)
+ (if (n/> branching-exponent level)
(case [(array;read +1 root) (array;read +0 root)]
[#;None (#;Some (#Hierarchy sub-node))]
(recur (level-down level) sub-node)
@@ -338,7 +338,7 @@
[level root]))))
]]
(wrap (|> vec
- (update@ #size n.dec)
+ (update@ #size n/dec)
(set@ #level level')
(set@ #root root')
(set@ #tail new-tail))))))
@@ -363,7 +363,7 @@
(def: #export empty?
(All [a] (-> (Sequence a) Bool))
- (|>. (get@ #size) (n.= +0)))
+ (|>. (get@ #size) (n/= +0)))
## [Syntax]
(syntax: #export (sequence [elems (p;some s;any)])
@@ -386,7 +386,7 @@
(struct: #export (Eq<Sequence> Eq<a>) (All [a] (-> (Eq a) (Eq (Sequence a))))
(def: (= v1 v2)
- (and (n.= (get@ #size v1) (get@ #size v2))
+ (and (n/= (get@ #size v1) (get@ #size v2))
(let [(^open "Node/") (Eq<Node> Eq<a>)]
(and (Node/= (#Base (get@ #tail v1))
(#Base (get@ #tail v2)))
diff --git a/stdlib/source/lux/data/coll/set.lux b/stdlib/source/lux/data/coll/set.lux
index 328524a06..b8f860353 100644
--- a/stdlib/source/lux/data/coll/set.lux
+++ b/stdlib/source/lux/data/coll/set.lux
@@ -52,7 +52,7 @@
(def: #export (empty? set)
(All [a] (-> (Set a) Bool))
- (n.= +0 (dict;size set)))
+ (n/= +0 (dict;size set)))
(def: #export (sub? super sub)
(All [a] (-> (Set a) (Set a) Bool))
@@ -71,6 +71,6 @@
(def: eq Eq<Set>)
(def: (hash (^@ set [Hash<a> _]))
- (List/fold (function [elem acc] (n.+ (:: Hash<a> hash elem) acc))
+ (List/fold (function [elem acc] (n/+ (:: Hash<a> hash elem) acc))
+0
(to-list set))))
diff --git a/stdlib/source/lux/data/coll/stream.lux b/stdlib/source/lux/data/coll/stream.lux
index 43ed0087c..0f1297e8f 100644
--- a/stdlib/source/lux/data/coll/stream.lux
+++ b/stdlib/source/lux/data/coll/stream.lux
@@ -58,8 +58,8 @@
(def: #export (nth idx s)
(All [a] (-> Nat (Stream a) a))
(let [[h t] (cont;run s)]
- (if (n.> +0 idx)
- (nth (n.dec idx) t)
+ (if (n/> +0 idx)
+ (nth (n/dec idx) t)
h)))
(do-template [<taker> <dropper> <splitter> <pred-type> <pred-test> <pred-step>]
@@ -89,7 +89,7 @@
[(list) xs])))]
[take-while drop-while split-while (-> a Bool) (pred x) pred]
- [take drop split Nat (n.> +0 pred) (n.dec pred)]
+ [take drop split Nat (n/> +0 pred) (n/dec pred)]
)
(def: #export (unfold step init)
diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux
index 61ee1249a..17546902a 100644
--- a/stdlib/source/lux/data/color.lux
+++ b/stdlib/source/lux/data/color.lux
@@ -6,7 +6,7 @@
(type opaque)))
(def: rgb Nat +256)
-(def: top Nat (n.dec rgb))
+(def: top Nat (n/dec rgb))
(def: nat-to-frac (-> Nat Frac) (|>. nat-to-int int-to-frac))
(def: frac-to-nat (-> Frac Nat) (|>. frac-to-int int-to-nat))
@@ -15,11 +15,11 @@
(def: scale-down
(-> Nat Frac)
- (|>. nat-to-frac (f./ rgb-factor)))
+ (|>. nat-to-frac (f// rgb-factor)))
(def: scale-up
(-> Frac Nat)
- (|>. (f.* rgb-factor) frac-to-nat))
+ (|>. (f/* rgb-factor) frac-to-nat))
(opaque: #export Color {}
{#red Nat
@@ -28,9 +28,9 @@
(def: #export (color [red green blue])
(-> [Nat Nat Nat] Color)
- (@opaque [(n.% rgb red)
- (n.% rgb green)
- (n.% rgb blue)]))
+ (@opaque [(n/% rgb red)
+ (n/% rgb green)
+ (n/% rgb blue)]))
(def: #export unpack
(-> Color [Nat Nat Nat])
@@ -40,9 +40,9 @@
(def: (= reference sample)
(let [[rr rg rb] (@repr reference)
[sr sg sb] (@repr sample)]
- (and (n.= rr sr)
- (n.= rg sg)
- (n.= rb sb)))))
+ (and (n/= rr sr)
+ (n/= rg sg)
+ (n/= rb sb)))))
)
(def: #export (to-hsl color)
@@ -51,67 +51,67 @@
red (scale-down red)
green (scale-down green)
blue (scale-down blue)
- max ($_ f.max red green blue)
- min ($_ f.min red green blue)
- luminance (|> (f.+ max min) (f./ 2.0))]
- (if (f.= max min)
+ max ($_ f/max red green blue)
+ min ($_ f/min red green blue)
+ luminance (|> (f/+ max min) (f// 2.0))]
+ (if (f/= max min)
## Achromatic
[0.0 0.0 luminance]
## Chromatic
- (let [diff (|> max (f.- min))
+ (let [diff (|> max (f/- min))
saturation (|> diff
- (f./ (if (f.> 0.5 luminance)
- (|> 2.0 (f.- max) (f.- min))
- (|> max (f.+ min)))))
- hue' (cond (f.= red max)
- (|> green (f.- blue) (f./ diff)
- (f.+ (if (f.< blue green) 6.0 0.0)))
+ (f// (if (f/> 0.5 luminance)
+ (|> 2.0 (f/- max) (f/- min))
+ (|> max (f/+ min)))))
+ hue' (cond (f/= red max)
+ (|> green (f/- blue) (f// diff)
+ (f/+ (if (f/< blue green) 6.0 0.0)))
- (f.= green max)
- (|> blue (f.- red) (f./ diff)
- (f.+ 2.0))
+ (f/= green max)
+ (|> blue (f/- red) (f// diff)
+ (f/+ 2.0))
- ## (f.= blue max)
- (|> red (f.- green) (f./ diff)
- (f.+ 4.0)))]
- [(|> hue' (f./ 6.0))
+ ## (f/= blue max)
+ (|> red (f/- green) (f// diff)
+ (f/+ 4.0)))]
+ [(|> hue' (f// 6.0))
saturation
luminance]))))
(def: (hue-to-rgb p q t)
(-> Frac Frac Frac Frac)
- (let [t (cond (f.< 0.0 t) (f.+ 1.0 t)
- (f.> 1.0 t) (f.- 1.0 t)
+ (let [t (cond (f/< 0.0 t) (f/+ 1.0 t)
+ (f/> 1.0 t) (f/- 1.0 t)
## else
t)
- f2/3 (f./ 3.0 2.0)]
- (cond (f.< (f./ 6.0 1.0) t)
- (|> q (f.- p) (f.* 6.0) (f.* t) (f.+ p))
+ f2/3 (f// 3.0 2.0)]
+ (cond (f/< (f// 6.0 1.0) t)
+ (|> q (f/- p) (f/* 6.0) (f/* t) (f/+ p))
- (f.< (f./ 2.0 1.0) t)
+ (f/< (f// 2.0 1.0) t)
q
- (f.< f2/3 t)
- (|> q (f.- p) (f.* (|> f2/3 (f.- t))) (f.* 6.0) (f.+ p))
+ (f/< f2/3 t)
+ (|> q (f/- p) (f/* (|> f2/3 (f/- t))) (f/* 6.0) (f/+ p))
## else
p)))
(def: #export (from-hsl [hue saturation luminance])
(-> [Frac Frac Frac] Color)
- (if (f.= 0.0 saturation)
+ (if (f/= 0.0 saturation)
## Achromatic
(let [intensity (scale-up luminance)]
(color [intensity intensity intensity]))
## Chromatic
- (let [q (if (f.< 0.5 luminance)
- (|> saturation (f.+ 1.0) (f.* luminance))
- (|> luminance (f.+ saturation) (f.- (f.* saturation luminance))))
- p (|> luminance (f.* 2.0) (f.- q))
- third (|> 1.0 (f./ 3.0))]
- (color [(scale-up (|> hue (f.+ third) (hue-to-rgb p q)))
+ (let [q (if (f/< 0.5 luminance)
+ (|> saturation (f/+ 1.0) (f/* luminance))
+ (|> luminance (f/+ saturation) (f/- (f/* saturation luminance))))
+ p (|> luminance (f/* 2.0) (f/- q))
+ third (|> 1.0 (f// 3.0))]
+ (color [(scale-up (|> hue (f/+ third) (hue-to-rgb p q)))
(scale-up (|> hue (hue-to-rgb p q)))
- (scale-up (|> hue (f.- third) (hue-to-rgb p q)))]))))
+ (scale-up (|> hue (f/- third) (hue-to-rgb p q)))]))))
(def: #export (to-hsb color)
(-> Color [Frac Frac Frac])
@@ -119,42 +119,42 @@
red (scale-down red)
green (scale-down green)
blue (scale-down blue)
- max ($_ f.max red green blue)
- min ($_ f.min red green blue)
+ max ($_ f/max red green blue)
+ min ($_ f/min red green blue)
brightness max
- diff (|> max (f.- min))
- saturation (if (f.= 0.0 max)
+ diff (|> max (f/- min))
+ saturation (if (f/= 0.0 max)
0.0
- (|> diff (f./ max)))]
- (if (f.= max min)
+ (|> diff (f// max)))]
+ (if (f/= max min)
## Achromatic
[0.0 saturation brightness]
## Chromatic
- (let [hue (cond (f.= red max)
- (|> green (f.- blue) (f./ diff)
- (f.+ (if (f.< blue green) 6.0 0.0)))
-
- (f.= green max)
- (|> blue (f.- red) (f./ diff)
- (f.+ 2.0))
-
- ## (f.= blue max)
- (|> red (f.- green) (f./ diff)
- (f.+ 4.0)))]
- [(|> hue (f./ 6.0))
+ (let [hue (cond (f/= red max)
+ (|> green (f/- blue) (f// diff)
+ (f/+ (if (f/< blue green) 6.0 0.0)))
+
+ (f/= green max)
+ (|> blue (f/- red) (f// diff)
+ (f/+ 2.0))
+
+ ## (f/= blue max)
+ (|> red (f/- green) (f// diff)
+ (f/+ 4.0)))]
+ [(|> hue (f// 6.0))
saturation
brightness]))))
(def: #export (from-hsb [hue saturation brightness])
(-> [Frac Frac Frac] Color)
- (let [hue (|> hue (f.* 6.0))
+ (let [hue (|> hue (f/* 6.0))
i (math;floor hue)
- f (|> hue (f.- i))
- p (|> 1.0 (f.- saturation) (f.* brightness))
- q (|> 1.0 (f.- (f.* f saturation)) (f.* brightness))
- t (|> 1.0 (f.- (|> 1.0 (f.- f) (f.* saturation))) (f.* brightness))
+ f (|> hue (f/- i))
+ p (|> 1.0 (f/- saturation) (f/* brightness))
+ q (|> 1.0 (f/- (f/* f saturation)) (f/* brightness))
+ t (|> 1.0 (f/- (|> 1.0 (f/- f) (f/* saturation))) (f/* brightness))
v brightness
- mod (|> i (f.% 6.0) frac-to-nat)
+ mod (|> i (f/% 6.0) frac-to-nat)
red (case mod +0 v +1 q +2 p +3 p +4 t +5 v _ (undefined))
green (case mod +0 t +1 v +2 v +3 q +4 p +5 p _ (undefined))
blue (case mod +0 p +1 p +2 t +3 v +4 v +5 q _ (undefined))]
@@ -168,34 +168,34 @@
red (scale-down red)
green (scale-down green)
blue (scale-down blue)
- key (|> 1.0 (f.- ($_ f.max red green blue)))
- f (if (f.< 1.0 key)
- (|> 1.0 (f./ (|> 1.0 (f.- key))))
+ key (|> 1.0 (f/- ($_ f/max red green blue)))
+ f (if (f/< 1.0 key)
+ (|> 1.0 (f// (|> 1.0 (f/- key))))
0.0)
- cyan (|> 1.0 (f.- red) (f.- key) (f.* f))
- magenta (|> 1.0 (f.- green) (f.- key) (f.* f))
- yellow (|> 1.0 (f.- blue) (f.- key) (f.* f))]
+ cyan (|> 1.0 (f/- red) (f/- key) (f/* f))
+ magenta (|> 1.0 (f/- green) (f/- key) (f/* f))
+ yellow (|> 1.0 (f/- blue) (f/- key) (f/* f))]
[cyan magenta yellow key]))
(def: #export (from-cmyk [cyan magenta yellow key])
(-> [Frac Frac Frac Frac] Color)
- (if (f.= 1.0 key)
+ (if (f/= 1.0 key)
(color [+0 +0 +0])
- (let [red (|> (|> 1.0 (f.- cyan))
- (f.* (|> 1.0 (f.- key))))
- green (|> (|> 1.0 (f.- magenta))
- (f.* (|> 1.0 (f.- key))))
- blue (|> (|> 1.0 (f.- yellow))
- (f.* (|> 1.0 (f.- key))))]
+ (let [red (|> (|> 1.0 (f/- cyan))
+ (f/* (|> 1.0 (f/- key))))
+ green (|> (|> 1.0 (f/- magenta))
+ (f/* (|> 1.0 (f/- key))))
+ blue (|> (|> 1.0 (f/- yellow))
+ (f/* (|> 1.0 (f/- key))))]
(color [(scale-up red) (scale-up green) (scale-up blue)]))))
(def: (normalize ratio)
(-> Frac Frac)
- (cond (f.> 1.0 ratio)
- (f.% 1.0 ratio)
+ (cond (f/> 1.0 ratio)
+ (f/% 1.0 ratio)
- (f.< 0.0 ratio)
- (|> 1.0 (f.+ (f.% 1.0 ratio)))
+ (f/< 0.0 ratio)
+ (|> 1.0 (f/+ (f/% 1.0 ratio)))
## else
ratio))
@@ -203,11 +203,11 @@
(def: #export (interpolate ratio end start)
(-> Frac Color Color Color)
(let [dS (normalize ratio)
- dE (|> 1.0 (f.- dS))
+ dE (|> 1.0 (f/- dS))
interpolate' (: (-> Nat Nat Nat)
(function [end start]
- (frac-to-nat (f.+ (f.* dE (nat-to-frac end))
- (f.* dS (nat-to-frac start))))))
+ (frac-to-nat (f/+ (f/* dE (nat-to-frac end))
+ (f/* dS (nat-to-frac start))))))
[redS greenS blueS] (unpack start)
[redE greenE blueE] (unpack end)]
(color [(interpolate' redE redS)
@@ -229,7 +229,7 @@
(def: #export (complement color)
(-> Color Color)
(let [[red green blue] (unpack color)
- adjust (function [value] (|> top (n.- value)))]
+ adjust (function [value] (|> top (n/- value)))]
(;;color [(adjust red)
(adjust green)
(adjust blue)])))
@@ -240,12 +240,12 @@
(let [[hue saturation luminance] (to-hsl color)]
(from-hsl [hue
(|> saturation
- (f.* (|> 1.0 (<op> (normalize ratio))))
- (f.min 1.0))
+ (f/* (|> 1.0 (<op> (normalize ratio))))
+ (f/min 1.0))
luminance])))]
- [saturate f.+]
- [de-saturate f.-]
+ [saturate f/+]
+ [de-saturate f/-]
)
(def: #export (gray-scale color)
@@ -258,12 +258,12 @@
(-> Color [Color Color Color])
(let [[hue saturation luminance] (to-hsl color)]
[color
- (from-hsl [(|> hue (f.+ <1>) normalize) saturation luminance])
- (from-hsl [(|> hue (f.+ <2>) normalize) saturation luminance])]))]
+ (from-hsl [(|> hue (f/+ <1>) normalize) saturation luminance])
+ (from-hsl [(|> hue (f/+ <2>) normalize) saturation luminance])]))]
- [triad (|> 1.0 (f./ 3.0)) (|> 2.0 (f./ 3.0))]
- [clash (|> 1.0 (f./ 4.0)) (|> 3.0 (f./ 4.0))]
- [split-complement (|> 1.0 (f./ 5.0)) (|> 3.0 (f./ 5.0))]
+ [triad (|> 1.0 (f// 3.0)) (|> 2.0 (f// 3.0))]
+ [clash (|> 1.0 (f// 4.0)) (|> 3.0 (f// 4.0))]
+ [split-complement (|> 1.0 (f// 5.0)) (|> 3.0 (f// 5.0))]
)
(do-template [<name> <1> <2> <3>]
@@ -271,36 +271,36 @@
(-> Color [Color Color Color Color])
(let [[hue saturation luminance] (to-hsl color)]
[color
- (from-hsl [(|> hue (f.+ <1>) normalize) saturation luminance])
- (from-hsl [(|> hue (f.+ <2>) normalize) saturation luminance])
- (from-hsl [(|> hue (f.+ <3>) normalize) saturation luminance])]))]
+ (from-hsl [(|> hue (f/+ <1>) normalize) saturation luminance])
+ (from-hsl [(|> hue (f/+ <2>) normalize) saturation luminance])
+ (from-hsl [(|> hue (f/+ <3>) normalize) saturation luminance])]))]
- [square (|> 1.0 (f./ 4.0)) (|> 2.0 (f./ 4.0)) (|> 3.0 (f./ 4.0))]
- [tetradic (|> 2.0 (f./ 12.0)) (|> 6.0 (f./ 12.0)) (|> 8.0 (f./ 12.0))]
+ [square (|> 1.0 (f// 4.0)) (|> 2.0 (f// 4.0)) (|> 3.0 (f// 4.0))]
+ [tetradic (|> 2.0 (f// 12.0)) (|> 6.0 (f// 12.0)) (|> 8.0 (f// 12.0))]
)
(def: #export (analogous results slice color)
(-> Nat Frac Color (List Color))
- (if (n.= +0 results)
+ (if (n/= +0 results)
(list)
(let [[hue saturation luminance] (to-hsl color)
slice (normalize slice)]
(L/map (function [idx]
- (from-hsl [(|> idx nat-to-frac (f.* slice) (f.+ hue) normalize)
+ (from-hsl [(|> idx nat-to-frac (f/* slice) (f/+ hue) normalize)
saturation
luminance]))
- (list;n.range +0 (n.dec results))))))
+ (list;n/range +0 (n/dec results))))))
(def: #export (monochromatic results color)
(-> Nat Color (List Color))
- (if (n.= +0 results)
+ (if (n/= +0 results)
(list)
(let [[hue saturation brightness] (to-hsb color)
- slice (|> 1.0 (f./ (nat-to-frac results)))]
- (|> (list;n.range +0 (n.dec results))
+ slice (|> 1.0 (f// (nat-to-frac results)))]
+ (|> (list;n/range +0 (n/dec results))
(L/map (|>. nat-to-frac
- (f.* slice)
- (f.+ brightness)
+ (f/* slice)
+ (f/+ brightness)
normalize
[hue saturation]
from-hsb))))))
diff --git a/stdlib/source/lux/data/format/css.lux b/stdlib/source/lux/data/format/css.lux
index 0c4551e0a..2b0a1a03b 100644
--- a/stdlib/source/lux/data/format/css.lux
+++ b/stdlib/source/lux/data/format/css.lux
@@ -51,7 +51,7 @@
(format "rgba(" (|> red nat-to-int %i)
"," (|> green nat-to-int %i)
"," (|> blue nat-to-int %i)
- "," (if (d.= (:: number;Interval<Deg> top) alpha)
+ "," (if (d/= (:: number;Interval<Deg> top) alpha)
"1.0"
(format "0" (%d alpha)))
")")))
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index 029d8dde7..b007dba42 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -164,7 +164,7 @@
[#String text;Eq<Text>])
[(#Array xs) (#Array ys)]
- (and (n.= (sequence;size xs) (sequence;size ys))
+ (and (n/= (sequence;size xs) (sequence;size ys))
(list/fold (function [idx prev]
(and prev
(maybe;default false
@@ -176,7 +176,7 @@
(list;indices (sequence;size xs))))
[(#Object xs) (#Object ys)]
- (and (n.= (dict;size xs) (dict;size ys))
+ (and (n/= (dict;size xs) (dict;size ys))
(list/fold (function [[xk xv] prev]
(and prev
(case (dict;get xk ys)
diff --git a/stdlib/source/lux/data/format/xml.lux b/stdlib/source/lux/data/format/xml.lux
index 1e705e513..64b45851d 100644
--- a/stdlib/source/lux/data/format/xml.lux
+++ b/stdlib/source/lux/data/format/xml.lux
@@ -235,7 +235,7 @@
(#Node sample/tag sample/attrs sample/children)]
(and (ident/= reference/tag sample/tag)
(:: (d;Eq<Dict> text;Eq<Text>) = reference/attrs sample/attrs)
- (n.= (list;size reference/children)
+ (n/= (list;size reference/children)
(list;size sample/children))
(|> (list;zip2 reference/children sample/children)
(list;every? (product;uncurry =))))
diff --git a/stdlib/source/lux/data/ident.lux b/stdlib/source/lux/data/ident.lux
index 592f648ba..24fe97221 100644
--- a/stdlib/source/lux/data/ident.lux
+++ b/stdlib/source/lux/data/ident.lux
@@ -49,4 +49,4 @@
(def: (hash [module name])
(let [(^open) text;Hash<Text>]
- (n.+ (hash module) (hash name)))))
+ (n/+ (hash module) (hash name)))))
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index 446e1e152..2749d566c 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -17,10 +17,10 @@
[(struct: #export _ (Eq <type>)
(def: = <test>))]
- [ Nat n.=]
- [ Int i.=]
- [ Deg d.=]
- [Frac f.=]
+ [ Nat n/=]
+ [ Int i/=]
+ [ Deg d/=]
+ [Frac f/=]
)
(do-template [<type> <eq> <lt> <lte> <gt> <gte>]
@@ -31,18 +31,18 @@
(def: > <gt>)
(def: >= <gte>))]
- [ Nat Eq<Nat> n.< n.<= n.> n.>=]
- [ Int Eq<Int> i.< i.<= i.> i.>=]
- [Deg Eq<Deg> d.< d.<= d.> d.>=]
- [Frac Eq<Frac> f.< f.<= f.> f.>=]
+ [ Nat Eq<Nat> n/< n/<= n/> n/>=]
+ [ Int Eq<Int> i/< i/<= i/> i/>=]
+ [Deg Eq<Deg> d/< d/<= d/> d/>=]
+ [Frac Eq<Frac> f/< f/<= f/> f/>=]
)
(struct: #export _ (Number Nat)
- (def: + n.+)
- (def: - n.-)
- (def: * n.*)
- (def: / n./)
- (def: % n.%)
+ (def: + n/+)
+ (def: - n/-)
+ (def: * n/*)
+ (def: / n//)
+ (def: % n/%)
(def: negate id)
(def: abs id)
(def: (signum x)
@@ -70,17 +70,17 @@
<1>))
)]
- [ Int Order<Int> i.+ i.- i.* i./ i.% i.= i.< 0 1 -1]
- [Frac Order<Frac> f.+ f.- f.* f./ f.% f.= f.< 0.0 1.0 -1.0]
+ [ Int Order<Int> i/+ i/- i/* i// i/% i/= i/< 0 1 -1]
+ [Frac Order<Frac> f/+ f/- f/* f// f/% f/= f/< 0.0 1.0 -1.0]
)
(struct: #export _ (Number Deg)
- (def: + d.+)
- (def: - d.-)
- (def: * d.*)
- (def: / d./)
- (def: % d.%)
- (def: (negate x) (d.- x ("lux deg max")))
+ (def: + d/+)
+ (def: - d/-)
+ (def: * d/*)
+ (def: / d//)
+ (def: % d/%)
+ (def: (negate x) (d/- x ("lux deg max")))
(def: abs id)
(def: (signum x)
("lux deg max")))
@@ -91,10 +91,10 @@
(def: succ <succ>)
(def: pred <pred>))]
- [Nat Order<Nat> n.inc n.dec]
- [Int Order<Int> i.inc i.dec]
- [Frac Order<Frac> (f.+ ("lux frac smallest")) (f.- ("lux frac smallest"))]
- [Deg Order<Deg> (d.+ ("lux deg min")) (d.- ("lux deg min"))]
+ [Nat Order<Nat> n/inc n/dec]
+ [Int Order<Int> i/inc i/dec]
+ [Frac Order<Frac> (f/+ ("lux frac smallest")) (f/- ("lux frac smallest"))]
+ [Deg Order<Deg> (d/+ ("lux deg min")) (d/- ("lux deg min"))]
)
(do-template [<type> <enum> <top> <bottom>]
@@ -114,22 +114,22 @@
(def: identity <identity>)
(def: compose <compose>))]
- [ Add@Monoid<Nat> Nat +0 n.+]
- [ Mul@Monoid<Nat> Nat +1 n.*]
- [ Max@Monoid<Nat> Nat (:: Interval<Nat> bottom) n.max]
- [ Min@Monoid<Nat> Nat (:: Interval<Nat> top) n.min]
- [ Add@Monoid<Int> Int 0 i.+]
- [ Mul@Monoid<Int> Int 1 i.*]
- [ Max@Monoid<Int> Int (:: Interval<Int> bottom) i.max]
- [ Min@Monoid<Int> Int (:: Interval<Int> top) i.min]
- [Add@Monoid<Frac> Frac 0.0 f.+]
- [Mul@Monoid<Frac> Frac 1.0 f.*]
- [Max@Monoid<Frac> Frac (:: Interval<Frac> bottom) f.max]
- [Min@Monoid<Frac> Frac (:: Interval<Frac> top) f.min]
- [ Add@Monoid<Deg> Deg (:: Interval<Deg> bottom) d.+]
- [ Mul@Monoid<Deg> Deg (:: Interval<Deg> top) d.*]
- [ Max@Monoid<Deg> Deg (:: Interval<Deg> bottom) d.max]
- [ Min@Monoid<Deg> Deg (:: Interval<Deg> top) d.min]
+ [ Add@Monoid<Nat> Nat +0 n/+]
+ [ Mul@Monoid<Nat> Nat +1 n/*]
+ [ Max@Monoid<Nat> Nat (:: Interval<Nat> bottom) n/max]
+ [ Min@Monoid<Nat> Nat (:: Interval<Nat> top) n/min]
+ [ Add@Monoid<Int> Int 0 i/+]
+ [ Mul@Monoid<Int> Int 1 i/*]
+ [ Max@Monoid<Int> Int (:: Interval<Int> bottom) i/max]
+ [ Min@Monoid<Int> Int (:: Interval<Int> top) i/min]
+ [Add@Monoid<Frac> Frac 0.0 f/+]
+ [Mul@Monoid<Frac> Frac 1.0 f/*]
+ [Max@Monoid<Frac> Frac (:: Interval<Frac> bottom) f/max]
+ [Min@Monoid<Frac> Frac (:: Interval<Frac> top) f/min]
+ [ Add@Monoid<Deg> Deg (:: Interval<Deg> bottom) d/+]
+ [ Mul@Monoid<Deg> Deg (:: Interval<Deg> top) d/*]
+ [ Max@Monoid<Deg> Deg (:: Interval<Deg> bottom) d/max]
+ [ Min@Monoid<Deg> Deg (:: Interval<Deg> top) d/min]
)
(do-template [<name> <const> <doc>]
@@ -146,13 +146,13 @@
(def: #export (not-a-number? number)
{#;doc "Tests whether a frac is actually not-a-number."}
(-> Frac Bool)
- (not (f.= number number)))
+ (not (f/= number number)))
(def: #export (frac? value)
(-> Frac Bool)
(not (or (not-a-number? value)
- (f.= positive-infinity value)
- (f.= negative-infinity value))))
+ (f/= positive-infinity value)
+ (f/= negative-infinity value))))
(do-template [<type> <encoder> <decoder> <error>]
[(struct: #export _ (Codec Text <type>)
@@ -173,37 +173,37 @@
## [Values & Syntax]
(def: (get-char full idx)
(-> Text Nat (Maybe Text))
- ("lux text clip" full idx (n.inc idx)))
+ ("lux text clip" full idx (n/inc idx)))
(do-template [<struct> <base> <char-set> <error>]
[(struct: #export <struct> (Codec Text Nat)
(def: (encode value)
(loop [input value
output ""]
- (let [digit (maybe;assume (get-char <char-set> (n.% <base> input)))
+ (let [digit (maybe;assume (get-char <char-set> (n/% <base> input)))
output' ("lux text concat" digit output)
- input' (n./ <base> input)]
- (if (n.= +0 input')
+ input' (n// <base> input)]
+ (if (n/= +0 input')
("lux text concat" "+" output')
(recur input' output')))))
(def: (decode repr)
(let [input-size ("lux text size" repr)]
- (if (n.>= +2 input-size)
+ (if (n/>= +2 input-size)
(case ("lux text char" repr +0)
(^ (#;Some (char "+")))
(let [input ("lux text upper" repr)]
(loop [idx +1
output +0]
- (if (n.< input-size idx)
+ (if (n/< input-size idx)
(let [digit (maybe;assume (get-char input idx))]
(case ("lux text index" <char-set> digit +0)
#;None
(#e;Error ("lux text concat" <error> repr))
(#;Some index)
- (recur (n.inc idx)
- (|> output (n.* <base>) (n.+ index)))))
+ (recur (n/inc idx)
+ (|> output (n/* <base>) (n/+ index)))))
(#e;Success output))))
_
@@ -219,24 +219,24 @@
(do-template [<struct> <base> <char-set> <error>]
[(struct: #export <struct> (Codec Text Int)
(def: (encode value)
- (if (i.= 0 value)
+ (if (i/= 0 value)
"0"
- (let [sign (if (i.< 0 value)
+ (let [sign (if (i/< 0 value)
"-"
"")]
- (loop [input (|> value (i./ <base>) (:: Number<Int> abs))
- output (|> value (i.% <base>) (:: Number<Int> abs) int-to-nat
+ (loop [input (|> value (i// <base>) (:: Number<Int> abs))
+ output (|> value (i/% <base>) (:: Number<Int> abs) int-to-nat
(get-char <char-set>)
maybe;assume)]
- (if (i.= 0 input)
+ (if (i/= 0 input)
("lux text concat" sign output)
- (let [digit (maybe;assume (get-char <char-set> (int-to-nat (i.% <base> input))))]
- (recur (i./ <base> input)
+ (let [digit (maybe;assume (get-char <char-set> (int-to-nat (i/% <base> input))))]
+ (recur (i// <base> input)
("lux text concat" digit output))))))))
(def: (decode repr)
(let [input-size ("lux text size" repr)]
- (if (n.>= +1 input-size)
+ (if (n/>= +1 input-size)
(let [sign (case (get-char repr +0)
(^ (#;Some "-"))
-1
@@ -244,18 +244,18 @@
_
1)
input ("lux text upper" repr)]
- (loop [idx (if (i.= -1 sign) +1 +0)
+ (loop [idx (if (i/= -1 sign) +1 +0)
output 0]
- (if (n.< input-size idx)
+ (if (n/< input-size idx)
(let [digit (maybe;assume (get-char input idx))]
(case ("lux text index" <char-set> digit +0)
#;None
(#e;Error <error>)
(#;Some index)
- (recur (n.inc idx)
- (|> output (i.* <base>) (i.+ (:! Int index))))))
- (#e;Success (i.* sign output)))))
+ (recur (n/inc idx)
+ (|> output (i/* <base>) (i/+ (:! Int index))))))
+ (#e;Success (i/* sign output)))))
(#e;Error <error>)))))]
[Binary@Codec<Text,Int> 2 "01" "Invalid binary syntax for Int: "]
@@ -272,20 +272,20 @@
[(struct: #export <struct> (Codec Text Deg)
(def: (encode value)
(let [raw-output (de-prefix (:: <nat> encode (:! Nat value)))
- max-num-chars (n./ <char-bit-size> +64)
+ max-num-chars (n// <char-bit-size> +64)
raw-size ("lux text size" raw-output)
- zero-padding (loop [zeroes-left (n.- raw-size max-num-chars)
+ zero-padding (loop [zeroes-left (n/- raw-size max-num-chars)
output ""]
- (if (n.= +0 zeroes-left)
+ (if (n/= +0 zeroes-left)
output
- (recur (n.dec zeroes-left)
+ (recur (n/dec zeroes-left)
("lux text concat" "0" output))))
padded-output ("lux text concat" zero-padding raw-output)]
("lux text concat" "." padded-output)))
(def: (decode repr)
(let [repr-size ("lux text size" repr)]
- (if (n.>= +2 repr-size)
+ (if (n/>= +2 repr-size)
(case ("lux text char" repr +0)
(^multi (^ (#;Some (char ".")))
[(:: <nat> decode ("lux text concat" "+" (de-prefix repr)))
@@ -306,17 +306,17 @@
(def: (encode value)
(let [whole (frac-to-int value)
whole-part (:: <int> encode whole)
- decimal (:: Number<Frac> abs (f.% 1.0 value))
- decimal-part (if (f.= 0.0 decimal)
+ decimal (:: Number<Frac> abs (f/% 1.0 value))
+ decimal-part (if (f/= 0.0 decimal)
".0"
(loop [dec-left decimal
output ""]
- (if (f.= 0.0 dec-left)
+ (if (f/= 0.0 dec-left)
("lux text concat" "." output)
- (let [shifted (f.* <base> dec-left)
- digit (|> shifted (f.% <base>) frac-to-int int-to-nat
+ (let [shifted (f/* <base> dec-left)
+ digit (|> shifted (f/% <base>) frac-to-int int-to-nat
(get-char <char-set>) maybe;assume)]
- (recur (f.% 1.0 shifted)
+ (recur (f/% 1.0 shifted)
("lux text concat" output digit))))))]
("lux text concat" whole-part decimal-part)))
@@ -324,29 +324,29 @@
(case ("lux text index" repr "." +0)
(#;Some split-index)
(let [whole-part (maybe;assume ("lux text clip" repr +0 split-index))
- decimal-part (maybe;assume ("lux text clip" repr (n.inc split-index) ("lux text size" repr)))]
+ decimal-part (maybe;assume ("lux text clip" repr (n/inc split-index) ("lux text size" repr)))]
(case [(:: <int> decode whole-part)
(:: <int> decode decimal-part)]
(^multi [(#e;Success whole) (#e;Success decimal)]
- (i.>= 0 decimal))
- (let [sign (if (i.< 0 whole)
+ (i/>= 0 decimal))
+ (let [sign (if (i/< 0 whole)
-1.0
1.0)
div-power (loop [muls-left ("lux text size" decimal-part)
output 1.0]
- (if (n.= +0 muls-left)
+ (if (n/= +0 muls-left)
output
- (recur (n.dec muls-left)
- (f.* <base> output))))
- adjusted-decimal (|> decimal int-to-frac (f./ div-power))
+ (recur (n/dec muls-left)
+ (f/* <base> output))))
+ adjusted-decimal (|> decimal int-to-frac (f// div-power))
dec-deg (case (:: Hex@Codec<Text,Deg> decode ("lux text concat" "." decimal-part))
(#e;Success dec-deg)
dec-deg
(#e;Error error)
(error! error))]
- (#e;Success (f.+ (int-to-frac whole)
- (f.* sign adjusted-decimal))))
+ (#e;Success (f/+ (int-to-frac whole)
+ (f/* sign adjusted-decimal))))
_
(#e;Error ("lux text concat" <error> repr))))
@@ -365,9 +365,9 @@
_
(let [num-digits ("lux text size" digits)]
- (if (n.<= chunk-size num-digits)
+ (if (n/<= chunk-size num-digits)
(list digits)
- (let [boundary (n.- chunk-size num-digits)
+ (let [boundary (n/- chunk-size num-digits)
chunk (maybe;assume ("lux text clip" digits boundary num-digits))
remaining (maybe;assume ("lux text clip" digits +0 boundary))]
(list& chunk (segment-digits chunk-size remaining)))))))
@@ -461,17 +461,17 @@
(do-template [<from> <from-translator> <to> <to-translator> <base-bits>]
[(def: (<from> on-left? input)
(-> Bool Text Text)
- (let [max-num-chars (n./ <base-bits> +64)
+ (let [max-num-chars (n// <base-bits> +64)
input-size ("lux text size" input)
- zero-padding (let [num-digits-that-need-padding (n.% <base-bits> input-size)]
- (if (n.= +0 num-digits-that-need-padding)
+ zero-padding (let [num-digits-that-need-padding (n/% <base-bits> input-size)]
+ (if (n/= +0 num-digits-that-need-padding)
""
- (loop [zeroes-left (n.- num-digits-that-need-padding
+ (loop [zeroes-left (n/- num-digits-that-need-padding
<base-bits>)
output ""]
- (if (n.= +0 zeroes-left)
+ (if (n/= +0 zeroes-left)
output
- (recur (n.dec zeroes-left)
+ (recur (n/dec zeroes-left)
("lux text concat" "0" output))))))
padded-input (if on-left?
("lux text concat" zero-padding input)
@@ -499,13 +499,13 @@
raw-bin (:: Binary@Codec<Text,Frac> encode value)
dot-idx (maybe;assume ("lux text index" raw-bin "." +0))
whole-part (maybe;assume ("lux text clip" raw-bin
- (if (f.= -1.0 sign) +1 +0)
+ (if (f/= -1.0 sign) +1 +0)
dot-idx))
- decimal-part (maybe;assume ("lux text clip" raw-bin (n.inc dot-idx) ("lux text size" raw-bin)))
+ decimal-part (maybe;assume ("lux text clip" raw-bin (n/inc dot-idx) ("lux text size" raw-bin)))
hex-output (|> (<from> false decimal-part)
("lux text concat" ".")
("lux text concat" (<from> true whole-part))
- ("lux text concat" (if (f.= -1.0 sign) "-" "")))]
+ ("lux text concat" (if (f/= -1.0 sign) "-" "")))]
hex-output))
(def: (decode repr)
@@ -517,12 +517,12 @@
1.0)]
(case ("lux text index" repr "." +0)
(#;Some split-index)
- (let [whole-part (maybe;assume ("lux text clip" repr (if (f.= -1.0 sign) +1 +0) split-index))
- decimal-part (maybe;assume ("lux text clip" repr (n.inc split-index) ("lux text size" repr)))
+ (let [whole-part (maybe;assume ("lux text clip" repr (if (f/= -1.0 sign) +1 +0) split-index))
+ decimal-part (maybe;assume ("lux text clip" repr (n/inc split-index) ("lux text size" repr)))
as-binary (|> (<to> decimal-part)
("lux text concat" ".")
("lux text concat" (<to> whole-part))
- ("lux text concat" (if (f.= -1.0 sign) "-" "")))]
+ ("lux text concat" (if (f/= -1.0 sign) "-" "")))]
(case (:: Binary@Codec<Text,Frac> decode as-binary)
(#e;Error _)
(#e;Error ("lux text concat" <error> repr))
@@ -611,13 +611,13 @@
(loop [idx idx
carry +0
output output]
- (if (i.>= 0 (:! Int idx))
+ (if (i/>= 0 (:! Int idx))
(let [raw (|> (digits-get idx output)
- (n.* +5)
- (n.+ carry))]
- (recur (n.dec idx)
- (n./ +10 raw)
- (digits-put idx (n.% +10 raw) output)))
+ (n/* +5)
+ (n/+ carry))]
+ (recur (n/dec idx)
+ (n// +10 raw)
+ (digits-put idx (n/% +10 raw) output)))
output)))
(def: (digits-power power)
@@ -625,22 +625,22 @@
(loop [times power
output (|> (make-digits [])
(digits-put power +1))]
- (if (i.>= 0 (:! Int times))
- (recur (n.dec times)
+ (if (i/>= 0 (:! Int times))
+ (recur (n/dec times)
(digits-times-5! power output))
output)))
(def: (digits-to-text digits)
(-> Digits Text)
- (loop [idx (n.dec bit;width)
+ (loop [idx (n/dec bit;width)
all-zeroes? true
output ""]
- (if (i.>= 0 (:! Int idx))
+ (if (i/>= 0 (:! Int idx))
(let [digit (digits-get idx digits)]
- (if (and (n.= +0 digit)
+ (if (and (n/= +0 digit)
all-zeroes?)
- (recur (n.dec idx) true output)
- (recur (n.dec idx)
+ (recur (n/dec idx) true output)
+ (recur (n/dec idx)
false
("lux text concat"
(:: Codec<Text,Int> encode (:! Int digit))
@@ -651,33 +651,33 @@
(def: (digits-add param subject)
(-> Digits Digits Digits)
- (loop [idx (n.dec bit;width)
+ (loop [idx (n/dec bit;width)
carry +0
output (make-digits [])]
- (if (i.>= 0 (:! Int idx))
- (let [raw ($_ n.+
+ (if (i/>= 0 (:! Int idx))
+ (let [raw ($_ n/+
carry
(digits-get idx param)
(digits-get idx subject))]
- (recur (n.dec idx)
- (n./ +10 raw)
- (digits-put idx (n.% +10 raw) output)))
+ (recur (n/dec idx)
+ (n// +10 raw)
+ (digits-put idx (n/% +10 raw) output)))
output)))
(def: (text-to-digits input)
(-> Text (Maybe Digits))
(let [length ("lux text size" input)]
- (if (n.<= bit;width length)
+ (if (n/<= bit;width length)
(loop [idx +0
output (make-digits [])]
- (if (n.< length idx)
+ (if (n/< length idx)
(let [char (maybe;assume (get-char input idx))]
(case ("lux text index" "0123456789" char +0)
#;None
#;None
(#;Some digit)
- (recur (n.inc idx)
+ (recur (n/inc idx)
(digits-put idx digit output))))
(#;Some output)))
#;None)))
@@ -685,49 +685,49 @@
(def: (digits-lt param subject)
(-> Digits Digits Bool)
(loop [idx +0]
- (and (n.< bit;width idx)
+ (and (n/< bit;width idx)
(let [pd (digits-get idx param)
sd (digits-get idx subject)]
- (if (n.= pd sd)
- (recur (n.inc idx))
- (n.< pd sd))))))
+ (if (n/= pd sd)
+ (recur (n/inc idx))
+ (n/< pd sd))))))
(def: (digits-sub-once! idx param subject)
(-> Nat Nat Digits Digits)
(let [sd (digits-get idx subject)]
- (if (n.>= param sd)
- (digits-put idx (n.- param sd) subject)
+ (if (n/>= param sd)
+ (digits-put idx (n/- param sd) subject)
(let [diff (|> sd
- (n.+ +10)
- (n.- param))]
+ (n/+ +10)
+ (n/- param))]
(|> subject
(digits-put idx diff)
- (digits-sub-once! (n.dec idx) +1))))))
+ (digits-sub-once! (n/dec idx) +1))))))
(def: (digits-sub! param subject)
(-> Digits Digits Digits)
- (loop [idx (n.dec bit;width)
+ (loop [idx (n/dec bit;width)
output subject]
- (if (i.>= 0 (nat-to-int idx))
- (recur (n.dec idx)
+ (if (i/>= 0 (nat-to-int idx))
+ (recur (n/dec idx)
(digits-sub-once! idx (digits-get idx param) output))
output)))
(struct: #export _ (Codec Text Deg)
(def: (encode input)
(let [input (:! Nat input)
- last-idx (n.dec bit;width)]
- (if (n.= +0 input)
+ last-idx (n/dec bit;width)]
+ (if (n/= +0 input)
".0"
(loop [idx last-idx
digits (make-digits [])]
- (if (i.>= 0 (:! Int idx))
+ (if (i/>= 0 (:! Int idx))
(if (bit;set? idx input)
- (let [digits' (digits-add (digits-power (n.- idx last-idx))
+ (let [digits' (digits-add (digits-power (n/- idx last-idx))
digits)]
- (recur (n.dec idx)
+ (recur (n/dec idx)
digits'))
- (recur (n.dec idx)
+ (recur (n/dec idx)
digits))
("lux text concat" "." (digits-to-text digits))
)))))
@@ -741,7 +741,7 @@
_
false)]
(if (and dotted?
- (n.<= (n.inc bit;width) length))
+ (n/<= (n/inc bit;width) length))
(case (|> ("lux text clip" input +1 length)
maybe;assume
text-to-digits)
@@ -749,14 +749,14 @@
(loop [digits digits
idx +0
output +0]
- (if (n.< bit;width idx)
+ (if (n/< bit;width idx)
(let [power (digits-power idx)]
(if (digits-lt power digits)
## Skip power
- (recur digits (n.inc idx) output)
+ (recur digits (n/inc idx) output)
(recur (digits-sub! power digits)
- (n.inc idx)
- (bit;set (n.- idx (n.dec bit;width)) output))))
+ (n/inc idx)
+ (bit;set (n/- idx (n/dec bit;width)) output))))
(#e;Success (:! Deg output))))
#;None
@@ -766,7 +766,7 @@
(def: (log2 input)
(-> Frac Frac)
- (f./ ("lux math log" 2.0)
+ (f// ("lux math log" 2.0)
("lux math log" input)))
(def: double-bias Nat +1023)
@@ -779,15 +779,15 @@
(cond (not-a-number? input)
(hex "+7FF7FFFFFFFFFFFF")
- (f.= positive-infinity input)
+ (f/= positive-infinity input)
(hex "+7FF0000000000000")
- (f.= negative-infinity input)
+ (f/= negative-infinity input)
(hex "+FFF0000000000000")
- (f.= 0.0 input)
- (let [reciprocal (f./ input 1.0)]
- (if (f.= positive-infinity reciprocal)
+ (f/= 0.0 input)
+ (let [reciprocal (f// input 1.0)]
+ (if (f/= positive-infinity reciprocal)
## Positive zero
(hex "+0000000000000000")
## Negative zero
@@ -797,14 +797,14 @@
(let [sign (:: Number<Frac> signum input)
input (:: Number<Frac> abs input)
exponent ("lux math floor" (log2 input))
- exponent-mask (|> +1 (bit;shift-left exponent-size) n.dec)
+ exponent-mask (|> +1 (bit;shift-left exponent-size) n/dec)
mantissa (|> input
## Normalize
- (f./ ("lux math pow" 2.0 exponent))
+ (f// ("lux math pow" 2.0 exponent))
## Make it int-equivalent
- (f.* ("lux math pow" 2.0 52.0)))
- sign-bit (if (f.= -1.0 sign) +1 +0)
- exponent-bits (|> exponent frac-to-int int-to-nat (n.+ double-bias) (bit;and exponent-mask))
+ (f/* ("lux math pow" 2.0 52.0)))
+ sign-bit (if (f/= -1.0 sign) +1 +0)
+ exponent-bits (|> exponent frac-to-int int-to-nat (n/+ double-bias) (bit;and exponent-mask))
mantissa-bits (|> mantissa frac-to-int int-to-nat)]
($_ bit;or
(bit;shift-left +63 sign-bit)
@@ -813,14 +813,14 @@
))
(do-template [<getter> <mask> <size> <offset>]
- [(def: <mask> (|> +1 (bit;shift-left <size>) n.dec (bit;shift-left <offset>)))
+ [(def: <mask> (|> +1 (bit;shift-left <size>) n/dec (bit;shift-left <offset>)))
(def: (<getter> input)
(-> Nat Nat)
(|> input (bit;and <mask>) (bit;shift-right <offset>)))]
[mantissa mantissa-mask mantissa-size +0]
[exponent exponent-mask exponent-size mantissa-size]
- [sign sign-mask +1 (n.+ exponent-size mantissa-size)]
+ [sign sign-mask +1 (n/+ exponent-size mantissa-size)]
)
(def: #export (bits-to-frac input)
@@ -828,30 +828,30 @@
(let [S (sign input)
E (exponent input)
M (mantissa input)]
- (cond (n.= (hex "+7FF") E)
- (if (n.= +0 M)
- (if (n.= +0 S)
+ (cond (n/= (hex "+7FF") E)
+ (if (n/= +0 M)
+ (if (n/= +0 S)
positive-infinity
negative-infinity)
not-a-number)
- (and (n.= +0 E) (n.= +0 M))
- (if (n.= +0 S)
+ (and (n/= +0 E) (n/= +0 M))
+ (if (n/= +0 S)
0.0
- (f.* -1.0 0.0))
+ (f/* -1.0 0.0))
## else
(let [normalized (|> M (bit;set mantissa-size)
nat-to-int int-to-frac
- (f./ ("lux math pow" 2.0 52.0)))
- power (|> E (n.- double-bias)
+ (f// ("lux math pow" 2.0 52.0)))
+ power (|> E (n/- double-bias)
nat-to-int int-to-frac
("lux math pow" 2.0))
- shifted (f.* power
+ shifted (f/* power
normalized)]
- (if (n.= +0 S)
+ (if (n/= +0 S)
shifted
- (f.* -1.0 shifted))))))
+ (f/* -1.0 shifted))))))
## [Hash]
(struct: #export _ (Hash Nat)
diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux
index 7fc8af1dd..15fee133f 100644
--- a/stdlib/source/lux/data/number/complex.lux
+++ b/stdlib/source/lux/data/number/complex.lux
@@ -6,7 +6,7 @@
codec
["M" monad #+ do Monad]
["p" parser])
- (data [number "f/" Number<Frac> Codec<Text,Frac>]
+ (data [number "frac/" Number<Frac> "f/" Codec<Text,Frac>]
[text "text/" Monoid<Text>]
text/format
["E" error]
@@ -41,9 +41,9 @@
(def: #export (c.= param input)
(-> Complex Complex Bool)
- (and (f.= (get@ #real param)
+ (and (f/= (get@ #real param)
(get@ #real input))
- (f.= (get@ #imaginary param)
+ (f/= (get@ #imaginary param)
(get@ #imaginary input))))
(do-template [<name> <op>]
@@ -54,8 +54,8 @@
#imaginary (<op> (get@ #imaginary param)
(get@ #imaginary input))})]
- [c.+ f.+]
- [c.- f.-]
+ [c.+ f/+]
+ [c.- f/-]
)
(struct: #export _ (Eq Complex)
@@ -63,55 +63,55 @@
(def: #export c.negate
(-> Complex Complex)
- (|>. (update@ #real f/negate)
- (update@ #imaginary f/negate)))
+ (|>. (update@ #real frac/negate)
+ (update@ #imaginary frac/negate)))
(def: #export c.signum
(-> Complex Complex)
- (|>. (update@ #real f/signum)
- (update@ #imaginary f/signum)))
+ (|>. (update@ #real frac/signum)
+ (update@ #imaginary frac/signum)))
(def: #export conjugate
(-> Complex Complex)
- (update@ #imaginary f/negate))
+ (update@ #imaginary frac/negate))
(def: #export (c.*' param input)
(-> Frac Complex Complex)
- {#real (f.* param
+ {#real (f/* param
(get@ #real input))
- #imaginary (f.* param
+ #imaginary (f/* param
(get@ #imaginary input))})
(def: #export (c.* param input)
(-> Complex Complex Complex)
- {#real (f.- (f.* (get@ #imaginary param)
+ {#real (f/- (f/* (get@ #imaginary param)
(get@ #imaginary input))
- (f.* (get@ #real param)
+ (f/* (get@ #real param)
(get@ #real input)))
- #imaginary (f.+ (f.* (get@ #real param)
+ #imaginary (f/+ (f/* (get@ #real param)
(get@ #imaginary input))
- (f.* (get@ #imaginary param)
+ (f/* (get@ #imaginary param)
(get@ #real input)))})
(def: #export (c./ param input)
(-> Complex Complex Complex)
(let [(^slots [#real #imaginary]) param]
- (if (f.< (f/abs imaginary)
- (f/abs real))
- (let [quot (f./ imaginary real)
- denom (|> real (f.* quot) (f.+ imaginary))]
- {#real (|> (get@ #real input) (f.* quot) (f.+ (get@ #imaginary input)) (f./ denom))
- #imaginary (|> (get@ #imaginary input) (f.* quot) (f.- (get@ #real input)) (f./ denom))})
- (let [quot (f./ real imaginary)
- denom (|> imaginary (f.* quot) (f.+ real))]
- {#real (|> (get@ #imaginary input) (f.* quot) (f.+ (get@ #real input)) (f./ denom))
- #imaginary (|> (get@ #imaginary input) (f.- (f.* quot (get@ #real input))) (f./ denom))}))))
+ (if (f/< (frac/abs imaginary)
+ (frac/abs real))
+ (let [quot (f// imaginary real)
+ denom (|> real (f/* quot) (f/+ imaginary))]
+ {#real (|> (get@ #real input) (f/* quot) (f/+ (get@ #imaginary input)) (f// denom))
+ #imaginary (|> (get@ #imaginary input) (f/* quot) (f/- (get@ #real input)) (f// denom))})
+ (let [quot (f// real imaginary)
+ denom (|> imaginary (f/* quot) (f/+ real))]
+ {#real (|> (get@ #imaginary input) (f/* quot) (f/+ (get@ #real input)) (f// denom))
+ #imaginary (|> (get@ #imaginary input) (f/- (f/* quot (get@ #real input))) (f// denom))}))))
(def: #export (c./' param subject)
(-> Frac Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (f./ param real)
- #imaginary (f./ param imaginary)}))
+ {#real (f// param real)
+ #imaginary (f// param imaginary)}))
(def: #export (c.% param input)
(-> Complex Complex Complex)
@@ -125,68 +125,68 @@
(def: #export (cos subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (f.* (math;cosh imaginary)
+ {#real (f/* (math;cosh imaginary)
(math;cos real))
- #imaginary (f.* (math;sinh imaginary)
- (f/negate (math;sin real)))}))
+ #imaginary (f/* (math;sinh imaginary)
+ (frac/negate (math;sin real)))}))
(def: #export (cosh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (f.* (math;cos imaginary)
+ {#real (f/* (math;cos imaginary)
(math;cosh real))
- #imaginary (f.* (math;sin imaginary)
+ #imaginary (f/* (math;sin imaginary)
(math;sinh real))}))
(def: #export (sin subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (f.* (math;cosh imaginary)
+ {#real (f/* (math;cosh imaginary)
(math;sin real))
- #imaginary (f.* (math;sinh imaginary)
+ #imaginary (f/* (math;sinh imaginary)
(math;cos real))}))
(def: #export (sinh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (f.* (math;cos imaginary)
+ {#real (f/* (math;cos imaginary)
(math;sinh real))
- #imaginary (f.* (math;sin imaginary)
+ #imaginary (f/* (math;sin imaginary)
(math;cosh real))}))
(def: #export (tan subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
- r2 (f.* 2.0 real)
- i2 (f.* 2.0 imaginary)
- d (f.+ (math;cos r2) (math;cosh i2))]
- {#real (f./ d (math;sin r2))
- #imaginary (f./ d (math;sinh i2))}))
+ r2 (f/* 2.0 real)
+ i2 (f/* 2.0 imaginary)
+ d (f/+ (math;cos r2) (math;cosh i2))]
+ {#real (f// d (math;sin r2))
+ #imaginary (f// d (math;sinh i2))}))
(def: #export (tanh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
- r2 (f.* 2.0 real)
- i2 (f.* 2.0 imaginary)
- d (f.+ (math;cosh r2) (math;cos i2))]
- {#real (f./ d (math;sinh r2))
- #imaginary (f./ d (math;sin i2))}))
+ r2 (f/* 2.0 real)
+ i2 (f/* 2.0 imaginary)
+ d (f/+ (math;cosh r2) (math;cos i2))]
+ {#real (f// d (math;sinh r2))
+ #imaginary (f// d (math;sin i2))}))
(def: #export (c.abs subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- (complex (if (f.< (f/abs imaginary)
- (f/abs real))
- (if (f.= 0.0 imaginary)
- (f/abs real)
- (let [q (f./ imaginary real)]
- (f.* (math;root2 (f.+ 1.0 (f.* q q)))
- (f/abs imaginary))))
- (if (f.= 0.0 real)
- (f/abs imaginary)
- (let [q (f./ real imaginary)]
- (f.* (math;root2 (f.+ 1.0 (f.* q q)))
- (f/abs real))))
+ (complex (if (f/< (frac/abs imaginary)
+ (frac/abs real))
+ (if (f/= 0.0 imaginary)
+ (frac/abs real)
+ (let [q (f// imaginary real)]
+ (f/* (math;root2 (f/+ 1.0 (f/* q q)))
+ (frac/abs imaginary))))
+ (if (f/= 0.0 real)
+ (frac/abs imaginary)
+ (let [q (f// real imaginary)]
+ (f/* (math;root2 (f/+ 1.0 (f/* q q)))
+ (frac/abs real))))
))))
(struct: #export _ (Number Complex)
@@ -197,20 +197,20 @@
(def: % c.%)
(def: (negate x)
(|> x
- (update@ #real f/negate)
- (update@ #imaginary f/negate)))
+ (update@ #real frac/negate)
+ (update@ #imaginary frac/negate)))
(def: abs c.abs)
(def: (signum x)
(|> x
- (update@ #real f/signum)
- (update@ #imaginary f/signum))))
+ (update@ #real frac/signum)
+ (update@ #imaginary frac/signum))))
(def: #export (exp subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
r-exp (math;exp real)]
- {#real (f.* r-exp (math;cos imaginary))
- #imaginary (f.* r-exp (math;sin imaginary))}))
+ {#real (f/* r-exp (math;cos imaginary))
+ #imaginary (f/* r-exp (math;sin imaginary))}))
(def: #export (log subject)
(-> Complex Complex)
@@ -229,18 +229,18 @@
(def: (copy-sign sign magnitude)
(-> Frac Frac Frac)
- (f.* (f/signum sign) magnitude))
+ (f/* (frac/signum sign) magnitude))
(def: #export (root2 (^@ input (^slots [#real #imaginary])))
(-> Complex Complex)
- (let [t (|> input c.abs (get@ #real) (f.+ (f/abs real)) (f./ 2.0) math;root2)]
- (if (f.>= 0.0 real)
+ (let [t (|> input c.abs (get@ #real) (f/+ (frac/abs real)) (f// 2.0) math;root2)]
+ (if (f/>= 0.0 real)
{#real t
- #imaginary (f./ (f.* 2.0 t)
+ #imaginary (f// (f/* 2.0 t)
imaginary)}
- {#real (f./ (f.* 2.0 t)
- (f/abs imaginary))
- #imaginary (f.* t (copy-sign imaginary 1.0))})))
+ {#real (f// (f/* 2.0 t)
+ (frac/abs imaginary))
+ #imaginary (f/* t (copy-sign imaginary 1.0))})))
(def: #export (root2-1z input)
(-> Complex Complex)
@@ -248,18 +248,18 @@
(def: #export (reciprocal (^slots [#real #imaginary]))
(-> Complex Complex)
- (if (f.< (f/abs imaginary)
- (f/abs real))
- (let [q (f./ imaginary real)
- scale (f./ (|> real (f.* q) (f.+ imaginary))
+ (if (f/< (frac/abs imaginary)
+ (frac/abs real))
+ (let [q (f// imaginary real)
+ scale (f// (|> real (f/* q) (f/+ imaginary))
1.0)]
- {#real (f.* q scale)
- #imaginary (f/negate scale)})
- (let [q (f./ real imaginary)
- scale (f./ (|> imaginary (f.* q) (f.+ real))
+ {#real (f/* q scale)
+ #imaginary (frac/negate scale)})
+ (let [q (f// real imaginary)
+ scale (f// (|> imaginary (f/* q) (f/+ real))
1.0)]
{#real scale
- #imaginary (|> scale f/negate (f.* q))})))
+ #imaginary (|> scale frac/negate (f/* q))})))
(def: #export (acos input)
(-> Complex Complex)
@@ -290,20 +290,20 @@
(def: #export (nth-roots nth input)
(-> Nat Complex (List Complex))
- (if (n.= +0 nth)
+ (if (n/= +0 nth)
(list)
(let [r-nth (|> nth nat-to-int int-to-frac)
- nth-root-of-abs (|> input c.abs (get@ #real) (math;pow (f./ r-nth 1.0)))
- nth-phi (|> input argument (f./ r-nth))
- slice (|> math;pi (f.* 2.0) (f./ r-nth))]
- (|> (list;n.range +0 (n.dec nth))
+ nth-root-of-abs (|> input c.abs (get@ #real) (math;pow (f// r-nth 1.0)))
+ nth-phi (|> input argument (f// r-nth))
+ slice (|> math;pi (f/* 2.0) (f// r-nth))]
+ (|> (list;n/range +0 (n/dec nth))
(L/map (function [nth']
(let [inner (|> nth' nat-to-int int-to-frac
- (f.* slice)
- (f.+ nth-phi))
- real (f.* nth-root-of-abs
+ (f/* slice)
+ (f/+ nth-phi))
+ real (f/* nth-root-of-abs
(math;cos inner))
- imaginary (f.* nth-root-of-abs
+ imaginary (f/* nth-root-of-abs
(math;sin inner))]
{#real real
#imaginary imaginary})))))))
diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux
index f3f9a1196..c056e740a 100644
--- a/stdlib/source/lux/data/number/ratio.lux
+++ b/stdlib/source/lux/data/number/ratio.lux
@@ -7,7 +7,7 @@
codec
monad
["p" parser])
- (data [number "n/" Number<Nat> Codec<Text,Nat>]
+ (data [number "n/" Codec<Text,Nat>]
[text "Text/" Monoid<Text>]
text/format
["E" error]
@@ -24,69 +24,69 @@
(def: #hidden (normalize (^slots [#numerator #denominator]))
(-> Ratio Ratio)
(let [common (math;gcd numerator denominator)]
- {#numerator (n./ common numerator)
- #denominator (n./ common denominator)}))
+ {#numerator (n// common numerator)
+ #denominator (n// common denominator)}))
(def: #export (q.* param input)
(-> Ratio Ratio Ratio)
- (normalize [(n.* (get@ #numerator param)
+ (normalize [(n/* (get@ #numerator param)
(get@ #numerator input))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #denominator input))]))
(def: #export (q./ param input)
(-> Ratio Ratio Ratio)
- (normalize [(n.* (get@ #denominator param)
+ (normalize [(n/* (get@ #denominator param)
(get@ #numerator input))
- (n.* (get@ #numerator param)
+ (n/* (get@ #numerator param)
(get@ #denominator input))]))
(def: #export (q.+ param input)
(-> Ratio Ratio Ratio)
- (normalize [(n.+ (n.* (get@ #denominator input)
+ (normalize [(n/+ (n/* (get@ #denominator input)
(get@ #numerator param))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #numerator input)))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #denominator input))]))
(def: #export (q.- param input)
(-> Ratio Ratio Ratio)
- (normalize [(n.- (n.* (get@ #denominator input)
+ (normalize [(n/- (n/* (get@ #denominator input)
(get@ #numerator param))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #numerator input)))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #denominator input))]))
(def: #export (q.% param input)
(-> Ratio Ratio Ratio)
- (let [quot (n./ (n.* (get@ #denominator input)
+ (let [quot (n// (n/* (get@ #denominator input)
(get@ #numerator param))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #numerator input)))]
- (q.- (update@ #numerator (n.* quot) param)
+ (q.- (update@ #numerator (n/* quot) param)
input)))
(def: #export (q.= param input)
(-> Ratio Ratio Bool)
- (and (n.= (get@ #numerator param)
+ (and (n/= (get@ #numerator param)
(get@ #numerator input))
- (n.= (get@ #denominator param)
+ (n/= (get@ #denominator param)
(get@ #denominator input))))
(do-template [<name> <op>]
[(def: #export (<name> param input)
(-> Ratio Ratio Bool)
- (and (<op> (n.* (get@ #denominator input)
+ (and (<op> (n/* (get@ #denominator input)
(get@ #numerator param))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #numerator input)))))]
- [q.< n.<]
- [q.<= n.<=]
- [q.> n.>]
- [q.>= n.>=]
+ [q.< n/<]
+ [q.<= n/<=]
+ [q.> n/>]
+ [q.>= n/>=]
)
(do-template [<name> <comp>]
diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux
index fe57508cc..d4476b5c2 100644
--- a/stdlib/source/lux/data/text.lux
+++ b/stdlib/source/lux/data/text.lux
@@ -58,7 +58,7 @@
(def: (last-index-of'' part part-size since text)
(-> Text Nat Nat Text (Maybe Nat))
- (case ("lux text index" text part (n.+ part-size since))
+ (case ("lux text index" text part (n/+ part-size since))
#;None
(#;Some since)
@@ -96,8 +96,8 @@
(-> Text Text Bool)
(case (last-index-of postfix x)
(#;Some n)
- (n.= (size x)
- (n.+ (size postfix) n))
+ (n/= (size x)
+ (n/+ (size postfix) n))
_
false))
diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux
index 5fc638354..354dc29a9 100644
--- a/stdlib/source/lux/data/text/lexer.lux
+++ b/stdlib/source/lux/data/text/lexer.lux
@@ -33,7 +33,7 @@
(#E;Error msg)
(#E;Success [[end-offset _] output])
- (if (n.= end-offset (text;size input))
+ (if (n/= end-offset (text;size input))
(#E;Success output)
(#E;Error (unconsumed-input-error end-offset input)))
))
@@ -44,7 +44,7 @@
(function [[offset tape]]
(case (text;nth offset tape)
(#;Some output)
- (#E;Success [[(n.inc offset) tape] (text;from-code output)])
+ (#E;Success [[(n/inc offset) tape] (text;from-code output)])
_
(#E;Error cannot-lex-error))
@@ -67,8 +67,8 @@
(function [[offset tape]]
(case (text;index-of' reference offset tape)
(#;Some where)
- (if (n.= offset where)
- (#E;Success [[(n.+ (text;size reference) offset) tape] []])
+ (if (n/= offset where)
+ (#E;Success [[(n/+ (text;size reference) offset) tape] []])
(#E;Error ($_ text/compose "Could not match: " (text;encode reference) " @ " (maybe;assume (text;clip' offset tape)))))
_
@@ -79,8 +79,8 @@
(-> Text (Lexer Bool))
(function [(^@ input [offset tape])]
(case (text;index-of' reference offset tape)
- (^multi (#;Some where) (n.= offset where))
- (#E;Success [[(n.+ (text;size reference) offset) tape] true])
+ (^multi (#;Some where) (n/= offset where))
+ (#E;Success [[(n/+ (text;size reference) offset) tape] true])
_
(#E;Success [input false]))))
@@ -89,7 +89,7 @@
{#;doc "Ensure the lexer's input is empty."}
(Lexer Unit)
(function [(^@ input [offset tape])]
- (if (n.= offset (text;size tape))
+ (if (n/= offset (text;size tape))
(#E;Success [input []])
(#E;Error (unconsumed-input-error offset tape)))))
@@ -97,7 +97,7 @@
{#;doc "Ask if the lexer's input is empty."}
(Lexer Bool)
(function [(^@ input [offset tape])]
- (#E;Success [input (n.= offset (text;size tape))])))
+ (#E;Success [input (n/= offset (text;size tape))])))
(def: #export peek
{#;doc "Lex the next character (without consuming it from the input)."}
@@ -124,8 +124,8 @@
[char any
#let [char' (maybe;assume (text;nth +0 char))]
_ (p;assert ($_ text/compose "Character is not within range: " (text;from-code bottom) "-" (text;from-code top))
- (and (n.>= bottom char')
- (n.<= top char')))]
+ (and (n/>= bottom char')
+ (n/<= top char')))]
(wrap char)))
(do-template [<name> <bottom> <top> <desc>]
@@ -166,7 +166,7 @@
(#;Some output)
(let [output (text;from-code output)]
(if (text;contains? output options)
- (#E;Success [[(n.inc offset) tape] output])
+ (#E;Success [[(n/inc offset) tape] output])
(#E;Error ($_ text/compose "Character (" output ") is not one of: " options))))
_
@@ -180,7 +180,7 @@
(#;Some output)
(let [output (text;from-code output)]
(if (;not (text;contains? output options))
- (#E;Success [[(n.inc offset) tape] output])
+ (#E;Success [[(n/inc offset) tape] output])
(#E;Error ($_ text/compose "Character (" output ") is one of: " options))))
_
@@ -193,7 +193,7 @@
(case (text;nth offset tape)
(#;Some output)
(if (p output)
- (#E;Success [[(n.inc offset) tape] (text;from-code output)])
+ (#E;Success [[(n/inc offset) tape] (text;from-code output)])
(#E;Error ($_ text/compose "Character does not satisfy predicate: " (text;from-code output))))
_
diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux
index 07e2a6ea4..d38111d7d 100644
--- a/stdlib/source/lux/data/text/regex.lux
+++ b/stdlib/source/lux/data/text/regex.lux
@@ -289,8 +289,8 @@
[idx (code;symbol ["" _name])]
#;None
- [(i.inc idx) (code;symbol ["" (Int/encode idx)])])
- access (if (n.> +0 num-captures)
+ [(i/inc idx) (code;symbol ["" (Int/encode idx)])])
+ access (if (n/> +0 num-captures)
(` (product;left (~ name!)))
name!)]
[idx!
@@ -348,7 +348,7 @@
(def: (prep-alternative [num-captures alt])
(-> [Nat Code] Code)
- (if (n.> +0 num-captures)
+ (if (n/> +0 num-captures)
alt
(` (unflatten^ (~ alt)))))
@@ -366,7 +366,7 @@
(` |||_^))]]
(if (list;empty? tail)
(wrap head)
- (wrap [(L/fold n.max (product;left head) (L/map product;left tail))
+ (wrap [(L/fold n/max (product;left head) (L/map product;left tail))
(` ($_ (~ g!op) (~ (prep-alternative head)) (~@ (L/map prep-alternative tail))))]))))
(def: (re-scoped^ current-module)
diff --git a/stdlib/source/lux/lang/syntax.lux b/stdlib/source/lux/lang/syntax.lux
index ae20fd9b6..a0d65cc89 100644
--- a/stdlib/source/lux/lang/syntax.lux
+++ b/stdlib/source/lux/lang/syntax.lux
@@ -54,14 +54,14 @@
(-> Cursor (l;Lexer [Cursor Text]))
(p;either (do p;Monad<Parser>
[content (l;many (l;one-of white-space))]
- (wrap [(update@ #;column (n.+ (text;size content)) where)
+ (wrap [(update@ #;column (n/+ (text;size content)) where)
content]))
## New-lines must be handled as a separate case to ensure line
## information is handled properly.
(do p;Monad<Parser>
[content (l;many (l;one-of new-line))]
(wrap [(|> where
- (update@ #;line (n.+ (text;size content)))
+ (update@ #;line (n/+ (text;size content)))
(set@ #;column +0))
content]))
))
@@ -75,7 +75,7 @@
comment (l;some (l;none-of new-line))
_ (l;this new-line)]
(wrap [(|> where
- (update@ #;line n.inc)
+ (update@ #;line n/inc)
(set@ #;column +0))
comment])))
@@ -98,21 +98,21 @@
(do p;Monad<Parser>
[_ (l;this "#(")]
(loop [comment ""
- where (update@ #;column (n.+ +2) where)]
+ where (update@ #;column (n/+ +2) where)]
($_ p;either
## These are normal chunks of commented text.
(do @
[chunk (l;many (l;not comment-bound^))]
(recur (format comment chunk)
(|> where
- (update@ #;column (n.+ (text;size chunk))))))
+ (update@ #;column (n/+ (text;size chunk))))))
## This is a special rule to handle new-lines within
## comments properly.
(do @
[_ (l;this new-line)]
(recur (format comment new-line)
(|> where
- (update@ #;line n.inc)
+ (update@ #;line n/inc)
(set@ #;column +0))))
## This is the rule for handling nested sub-comments.
## Ultimately, the whole comment is just treated as text
@@ -127,7 +127,7 @@
## Finally, this is the rule for closing the comment.
(do @
[_ (l;this ")#")]
- (wrap [(update@ #;column (n.+ +2) where)
+ (wrap [(update@ #;column (n/+ +2) where)
comment]))
))))
@@ -184,7 +184,7 @@
[code (l;between +1 +4 l;hexadecimal)]
(wrap (case (|> code (format "+") (:: number;Hex@Codec<Text,Nat> decode))
(#;Right value)
- [(n.+ +2 (text;size code)) (text;from-code value)]
+ [(n/+ +2 (text;size code)) (text;from-code value)]
_
(undefined))))
@@ -219,7 +219,7 @@
(p;fail error)
(#;Right value)
- (wrap [(update@ #;column (n.+ (text;size chunk)) where)
+ (wrap [(update@ #;column (n/+ (text;size chunk)) where)
[where (<tag> value)]]))))]
[bool #;Bool
@@ -247,19 +247,19 @@
(do @
[normal (l;none-of "\\\"\n")]
(wrap [(|> where
- (update@ #;column n.inc))
+ (update@ #;column n/inc))
normal]))
## Must handle escaped
## chars separately.
(do @
[[chars-consumed char] escaped-char^]
(wrap [(|> where
- (update@ #;column (n.+ chars-consumed)))
+ (update@ #;column (n/+ chars-consumed)))
char]))))
_ (l;this "\"")
#let [char (maybe;assume (text;nth +0 char))]]
(wrap [(|> where'
- (update@ #;column n.inc))
+ (update@ #;column n/inc))
[where (#;Nat char)]])))
(def: (normal-nat where)
@@ -272,7 +272,7 @@
(p;fail error)
(#;Right value)
- (wrap [(update@ #;column (n.+ (text;size chunk)) where)
+ (wrap [(update@ #;column (n/+ (text;size chunk)) where)
[where (#;Nat value)]]))))
(def: #export (nat where)
@@ -298,7 +298,7 @@
(p;fail error)
(#;Right value)
- (wrap [(update@ #;column (n.+ (text;size chunk)) where)
+ (wrap [(update@ #;column (n/+ (text;size chunk)) where)
[where (#;Frac value)]]))))
(def: frac-ratio-fragment
@@ -323,11 +323,11 @@
_ (l;this? "/")
denominator frac-ratio-fragment
_ (p;assert "Denominator cannot be 0."
- (not (f.= 0.0 denominator)))]
+ (not (f/= 0.0 denominator)))]
(wrap (|> numerator
- (f.* (if signed? -1.0 1.0))
- (f./ denominator)))))]
- (wrap [(update@ #;column (n.+ (text;size chunk)) where)
+ (f/* (if signed? -1.0 1.0))
+ (f// denominator)))))]
+ (wrap [(update@ #;column (n/+ (text;size chunk)) where)
[where (#;Frac value)]])))
(def: #export (frac where)
@@ -350,7 +350,7 @@
## as many spaces as necessary to be column-aligned.
## This helps ensure that the formatting on the text in the
## source-code matches the formatting of the Text value.
- #let [offset-column (n.inc (get@ #;column where))]
+ #let [offset-column (n/inc (get@ #;column where))]
[where' text-read] (: (l;Lexer [Cursor Text])
## I must keep track of how much of the
## text body has been read, how far the
@@ -359,7 +359,7 @@
## processing normal text body.
(loop [text-read ""
where (|> where
- (update@ #;column n.inc))
+ (update@ #;column n/inc))
must-have-offset? false]
(p;either (if must-have-offset?
## If I'm at the start of a
@@ -371,7 +371,7 @@
(do @
[offset (l;many (l;one-of " "))
#let [offset-size (text;size offset)]]
- (if (n.>= offset-column offset-size)
+ (if (n/>= offset-column offset-size)
## Any extra offset
## becomes part of the
## text's body.
@@ -381,7 +381,7 @@
product;right
(format text-read))
(|> where
- (update@ #;column (n.+ offset-size)))
+ (update@ #;column (n/+ offset-size)))
false)
(p;fail (format "Each line of a multi-line text must have an appropriate offset!\n"
"Expected: " (%i (nat-to-int offset-column)) " columns.\n"
@@ -392,7 +392,7 @@
[normal (l;many (l;none-of "\\\"\n"))]
(recur (format text-read normal)
(|> where
- (update@ #;column (n.+ (text;size normal))))
+ (update@ #;column (n/+ (text;size normal))))
false))
## Must handle escaped
## chars separately.
@@ -400,13 +400,13 @@
[[chars-consumed char] escaped-char^]
(recur (format text-read char)
(|> where
- (update@ #;column (n.+ chars-consumed)))
+ (update@ #;column (n/+ chars-consumed)))
false))
## The text ends when it
## reaches the right-delimiter.
(do @
[_ (l;this "\"")]
- (wrap [(update@ #;column n.inc where)
+ (wrap [(update@ #;column n/inc where)
text-read]))))
## If a new-line is
## encountered, it gets
@@ -417,7 +417,7 @@
[_ (l;this new-line)]
(recur (format text-read new-line)
(|> where
- (update@ #;line n.inc)
+ (update@ #;line n/inc)
(set@ #;column +0))
true)))))]
(wrap [where'
@@ -448,7 +448,7 @@
## end-delimiter.
where' (left-padding^ where)
_ (l;this <close>)]
- (wrap [(update@ #;column n.inc where')
+ (wrap [(update@ #;column n/inc where')
(sequence;to-list elems)]))))]
(wrap [where'
[where (<tag> elems)]])))]
@@ -483,7 +483,7 @@
(do @
[where' (left-padding^ where)
_ (l;this "}")]
- (wrap [(update@ #;column n.inc where')
+ (wrap [(update@ #;column n/inc where')
(sequence;to-list elems)]))))]
(wrap [where'
[where (#;Record elems)]])))
@@ -535,7 +535,7 @@
[_ (l;this current-module-mark)
def-name ident-part^]
(wrap [[current-module def-name]
- (n.+ +2 (text;size def-name))]))
+ (n/+ +2 (text;size def-name))]))
## If the identifier is prefixed by the mark, but no module
## part, the module is assumed to be "lux" (otherwise known as
## the 'prelude').
@@ -546,7 +546,7 @@
[_ (l;this identifier-separator)
def-name ident-part^]
(wrap [["lux" def-name]
- (n.inc (text;size def-name))]))
+ (n/inc (text;size def-name))]))
## Not all identifiers must be specified with a module part.
## If that part is not provided, the identifier will be created
## with the empty "" text as the module.
@@ -563,7 +563,7 @@
second-part ident-part^]
(wrap [[(|> aliases (dict;get first-part) (maybe;default first-part))
second-part]
- ($_ n.+
+ ($_ n/+
(text;size first-part)
+1
(text;size second-part))]))
@@ -582,7 +582,7 @@
(-> Text Aliases Cursor (l;Lexer [Cursor Code]))
(do p;Monad<Parser>
[[value length] <lexer>]
- (wrap [(update@ #;column (|>. ($_ n.+ <extra> length)) where)
+ (wrap [(update@ #;column (|>. ($_ n/+ <extra> length)) where)
[where (<tag> value)]])))]
[symbol #;Symbol (ident^ current-module aliases) +0]
diff --git a/stdlib/source/lux/lang/type.lux b/stdlib/source/lux/lang/type.lux
index d4a3d7d1b..217320ab2 100644
--- a/stdlib/source/lux/lang/type.lux
+++ b/stdlib/source/lux/lang/type.lux
@@ -48,7 +48,7 @@
(case [x y]
[(#;Primitive xname xparams) (#;Primitive yname yparams)]
(and (text/= xname yname)
- (n.= (list;size yparams) (list;size xparams))
+ (n/= (list;size yparams) (list;size xparams))
(list/fold (;function [[x y] prev] (and prev (= x y)))
true
(list;zip2 xparams yparams)))
@@ -60,7 +60,7 @@
(^template [<tag>]
[(<tag> xid) (<tag> yid)]
- (n.= yid xid))
+ (n/= yid xid))
([#;Var] [#;Ex] [#;Bound])
(^or [(#;Function xleft xright) (#;Function yleft yright)]
@@ -79,7 +79,7 @@
(^or [(#;UnivQ xenv xbody) (#;UnivQ yenv ybody)]
[(#;ExQ xenv xbody) (#;ExQ yenv ybody)])
- (and (n.= (list;size yenv) (list;size xenv))
+ (and (n/= (list;size yenv) (list;size xenv))
(= xbody ybody)
(list/fold (;function [[x y] prev] (and prev (= x y)))
true
@@ -97,7 +97,7 @@
type type]
(case type
(<tag> env sub-type)
- (recur (n.inc num-args) sub-type)
+ (recur (n/inc num-args) sub-type)
_
[num-args type])))]
@@ -323,7 +323,7 @@
(-> Nat Type Type)
(case size
+0 body
- _ (<tag> (list) (<name> (n.dec size) body))))]
+ _ (<tag> (list) (<name> (n/dec size) body))))]
[univ-q #;UnivQ]
[ex-q #;ExQ]
@@ -351,4 +351,4 @@
(-> Nat Type Type)
(case level
+0 elem-type
- _ (#;Primitive "#Array" (list (array (n.dec level) elem-type)))))
+ _ (#;Primitive "#Array" (list (array (n/dec level) elem-type)))))
diff --git a/stdlib/source/lux/lang/type/check.lux b/stdlib/source/lux/lang/type/check.lux
index 086866ddf..9dc1a6565 100644
--- a/stdlib/source/lux/lang/type/check.lux
+++ b/stdlib/source/lux/lang/type/check.lux
@@ -96,7 +96,7 @@
(#;Cons [var-id var-type]
plist')
- (if (n.= id var-id)
+ (if (n/= id var-id)
(#;Some var-type)
(var::get id plist'))
))
@@ -109,7 +109,7 @@
(#;Cons [var-id var-type]
plist')
- (if (n.= id var-id)
+ (if (n/= id var-id)
(#;Cons [var-id value]
plist')
(#;Cons [var-id var-type]
@@ -124,7 +124,7 @@
(#;Cons [var-id var-type]
plist')
- (if (n.= id var-id)
+ (if (n/= id var-id)
plist'
(#;Cons [var-id var-type]
(var::remove id plist')))
@@ -150,7 +150,7 @@
(Check [Nat Type])
(function [context]
(let [id (get@ #;ex-counter context)]
- (#e;Success [(update@ #;ex-counter n.inc context)
+ (#e;Success [(update@ #;ex-counter n/inc context)
[id (#;Ex id)]]))))
(do-template [<name> <outputT> <fail> <succeed>]
@@ -219,7 +219,7 @@
(function [context]
(let [id (get@ #;var-counter context)]
(#e;Success [(|> context
- (update@ #;var-counter n.inc)
+ (update@ #;var-counter n/inc)
(update@ #;var-bindings (var::put id #;None)))
[id (#;Var id)]]))))
@@ -270,7 +270,7 @@
(#;Some (#;Some type))
(case type
(#;Var post)
- (if (n.= id post)
+ (if (n/= id post)
(#e;Success [context output])
(recur post (set;add post output)))
@@ -344,7 +344,7 @@
then)
(do Monad<Check>
[ring (ring id)
- _ (assert "" (n.> +1 (set;size ring)))
+ _ (assert "" (n/> +1 (set;size ring)))
_ (monad;map @ (update type) (set;to-list ring))]
then)
(do Monad<Check>
@@ -368,7 +368,7 @@
(List Assumption)
Var Var
(Check (List Assumption)))
- (if (n.= idE idA)
+ (if (n/= idE idA)
(check/wrap assumptions)
(do Monad<Check>
[ebound (attempt (peek idE))
@@ -576,7 +576,7 @@
[(#;Primitive e-name e-params) (#;Primitive a-name a-params)]
(if (and (text/= e-name a-name)
- (n.= (list;size e-params)
+ (n/= (list;size e-params)
(list;size a-params)))
(do Monad<Check>
[assumptions (monad;fold Monad<Check>
@@ -603,7 +603,7 @@
(check' eO aO assumptions))
[(#;Ex e!id) (#;Ex a!id)]
- (if (n.= e!id a!id)
+ (if (n/= e!id a!id)
(check/wrap assumptions)
(fail ""))
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index e800efcd5..53fe18c82 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -363,7 +363,7 @@
A prefix can be given (or just be empty text \"\") to better identify the code for debugging purposes."}
(-> Text (Meta Code))
(function [compiler]
- (#e;Success [(update@ #;seed n.inc compiler)
+ (#e;Success [(update@ #;seed n/inc compiler)
(code;symbol ["" ($_ text/compose "__gensym__" prefix (:: number;Codec<Text,Nat> encode (get@ #;seed compiler)))])])))
(def: (get-local-symbol ast)
@@ -650,7 +650,7 @@
(<macro> #omit
(def: (foo bar baz)
(-> Int Int Int)
- (i.+ bar baz))))}
+ (i/+ bar baz))))}
(case tokens
(^ (list [_ (#;Tag ["" "omit"])]
token))
diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux
index bbed25f98..17a5cdc94 100644
--- a/stdlib/source/lux/macro/poly.lux
+++ b/stdlib/source/lux/macro/poly.lux
@@ -161,7 +161,7 @@
(do p;Monad<Parser>
[headT any]
(let [members (<flattener> (type;un-name headT))]
- (if (n.> +1 (list;size members))
+ (if (n/> +1 (list;size members))
(local members poly)
(p;fail ($_ text/compose "Not a " (ident/encode (ident-for <tag>)) " type: " (type;to-text headT)))))))]
@@ -174,7 +174,7 @@
(do p;Monad<Parser>
[headT any
#let [[num-arg bodyT] (type;flatten-univ-q (type;un-name headT))]]
- (if (n.= +0 num-arg)
+ (if (n/= +0 num-arg)
(p;fail ($_ text/compose "Non-polymorphic type: " (type;to-text headT)))
(wrap [num-arg bodyT]))))
@@ -189,21 +189,21 @@
[all-varsL env'] (loop [current-arg +0
env' env
all-varsL (: (List Code) (list))]
- (if (n.< num-args current-arg)
- (if (n.= +0 current-arg)
- (let [varL (label (n.inc funcI))]
- (recur (n.inc current-arg)
+ (if (n/< num-args current-arg)
+ (if (n/= +0 current-arg)
+ (let [varL (label (n/inc funcI))]
+ (recur (n/inc current-arg)
(|> env'
(dict;put funcI [headT funcL])
- (dict;put (n.inc funcI) [(#;Bound (n.inc funcI)) varL]))
+ (dict;put (n/inc funcI) [(#;Bound (n/inc funcI)) varL]))
(#;Cons varL all-varsL)))
- (let [partialI (|> current-arg (n.* +2) (n.+ funcI))
- partial-varI (n.inc partialI)
+ (let [partialI (|> current-arg (n/* +2) (n/+ funcI))
+ partial-varI (n/inc partialI)
partial-varL (label partial-varI)
- partialC (` ((~ funcL) (~@ (|> (list;n.range +0 (n.dec num-args))
- (list/map (|>. (n.* +2) n.inc (n.+ funcI) label))
+ partialC (` ((~ funcL) (~@ (|> (list;n/range +0 (n/dec num-args))
+ (list/map (|>. (n/* +2) n/inc (n/+ funcI) label))
list;reverse))))]
- (recur (n.inc current-arg)
+ (recur (n/inc current-arg)
(|> env'
(dict;put partialI [;Void partialC])
(dict;put partial-varI [(#;Bound partial-varI) partial-varL]))
@@ -220,7 +220,7 @@
(do p;Monad<Parser>
[headT any
#let [[inputsT outputT] (type;flatten-function (type;un-name headT))]]
- (if (n.> +0 (list;size inputsT))
+ (if (n/> +0 (list;size inputsT))
(p;seq (local inputsT in-poly)
(local (list outputT) out-poly))
(p;fail ($_ text/compose "Non-function type: " (type;to-text headT))))))
@@ -230,7 +230,7 @@
(do p;Monad<Parser>
[headT any
#let [[funcT paramsT] (type;flatten-application (type;un-name headT))]]
- (if (n.= +0 (list;size paramsT))
+ (if (n/= +0 (list;size paramsT))
(p;fail ($_ text/compose "Non-application type: " (type;to-text headT)))
(local (#;Cons funcT paramsT) poly))))
@@ -247,10 +247,10 @@
(def: (adjusted-idx env idx)
(-> Env Nat Nat)
- (let [env-level (n./ +2 (dict;size env))
- bound-level (n./ +2 idx)
- bound-idx (n.% +2 idx)]
- (|> env-level n.dec (n.- bound-level) (n.* +2) (n.+ bound-idx))))
+ (let [env-level (n// +2 (dict;size env))
+ bound-level (n// +2 idx)
+ bound-idx (n/% +2 idx)]
+ (|> env-level n/dec (n/- bound-level) (n/* +2) (n/+ bound-idx))))
(def: #export bound
(Poly Code)
@@ -276,7 +276,7 @@
headT any]
(case headT
(#;Bound idx)
- (if (n.= id (adjusted-idx env idx))
+ (if (n/= id (adjusted-idx env idx))
(wrap [])
(p;fail ($_ text/compose "Wrong bound type.\n"
"Expected: " (nat/encode id) "\n"
@@ -319,7 +319,7 @@
headT any]
(case (type;un-name headT)
(^multi (#;Apply #;Void (#;Bound funcT-idx))
- (n.= +0 (adjusted-idx env funcT-idx))
+ (n/= +0 (adjusted-idx env funcT-idx))
[(dict;get +0 env) (#;Some [self-type self-call])])
(wrap self-call)
@@ -426,13 +426,13 @@
(#;Bound idx)
(let [idx (adjusted-idx env idx)]
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(|> (dict;get idx env) maybe;assume product;left (to-ast env))
- (` (;$ (~ (code;nat (n.dec idx)))))))
+ (` (;$ (~ (code;nat (n/dec idx)))))))
(#;Apply #;Void (#;Bound idx))
(let [idx (adjusted-idx env idx)]
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(|> (dict;get idx env) maybe;assume product;left (to-ast env))
(undefined)))
diff --git a/stdlib/source/lux/macro/poly/eq.lux b/stdlib/source/lux/macro/poly/eq.lux
index 099febb24..a82b99814 100644
--- a/stdlib/source/lux/macro/poly/eq.lux
+++ b/stdlib/source/lux/macro/poly/eq.lux
@@ -110,7 +110,7 @@
## Tuples
(do @
[g!eqs (poly;tuple (p;many Eq<?>))
- #let [indices (|> (list;size g!eqs) n.dec (list;n.range +0))
+ #let [indices (|> (list;size g!eqs) n/dec (list;n/range +0))
g!lefts (list/map (|>. nat/encode (text/compose "left") code;local-symbol) indices)
g!rights (list/map (|>. nat/encode (text/compose "right") code;local-symbol) indices)]]
(wrap (` (: (~ (@Eq inputT))
diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux
index ba847d35b..2870fc63f 100644
--- a/stdlib/source/lux/macro/poly/functor.lux
+++ b/stdlib/source/lux/macro/poly/functor.lux
@@ -27,9 +27,9 @@
#let [num-vars (list;size varsC)]
#let [@Functor (: (-> Type Code)
(function [unwrappedT]
- (if (n.= +1 num-vars)
+ (if (n/= +1 num-vars)
(` (functor;Functor (~ (poly;to-ast *env* unwrappedT))))
- (let [paramsC (|> num-vars n.dec list;indices (L/map (|>. %n code;local-symbol)))]
+ (let [paramsC (|> num-vars n/dec list;indices (L/map (|>. %n code;local-symbol)))]
(` (All [(~@ paramsC)]
(functor;Functor ((~ (poly;to-ast *env* unwrappedT)) (~@ paramsC)))))))))
Arg<?> (: (-> Code (poly;Poly Code))
@@ -37,7 +37,7 @@
($_ p;either
## Type-var
(do p;Monad<Parser>
- [#let [varI (|> num-vars (n.* +2) n.dec)]
+ [#let [varI (|> num-vars (n/* +2) n/dec)]
_ (poly;var varI)]
(wrap (` ((~ funcC) (~ valueC)))))
## Variants
@@ -59,7 +59,7 @@
(do @
[_ (wrap [])
memberC (Arg<?> slotC)]
- (recur (n.inc idx)
+ (recur (n/inc idx)
(L/compose pairsCC (list [slotC memberC])))))
(wrap pairsCC)))))]
(wrap (` (case (~ valueC)
@@ -71,8 +71,8 @@
#let [outL (code;local-symbol "\u0000outL")]
[inT+ outC] (poly;function (p;many poly;any)
(Arg<?> outL))
- #let [inC+ (|> (list;size inT+) n.dec
- (list;n.range +0)
+ #let [inC+ (|> (list;size inT+) n/dec
+ (list;n/range +0)
(L/map (|>. %n (format "\u0000inC") code;local-symbol)))]]
(wrap (` (function [(~@ inC+)]
(let [(~ outL) ((~ valueC) (~@ inC+))]
diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux
index 6b4d5fed5..02352109a 100644
--- a/stdlib/source/lux/macro/poly/json.lux
+++ b/stdlib/source/lux/macro/poly/json.lux
@@ -43,7 +43,7 @@
(function [input]
(non-rec (rec-encode non-rec) input)))
-(def: low-mask Nat (|> +1 (bit;shift-left +32) n.dec))
+(def: low-mask Nat (|> +1 (bit;shift-left +32) n/dec))
(def: high-mask Nat (|> low-mask (bit;shift-left +32)))
(struct: #hidden _ (Codec JSON Nat)
@@ -57,7 +57,7 @@
(do p;Monad<Parser>
[high //;number
low //;number])
- (wrap (n.+ (|> high frac-to-int int-to-nat (bit;shift-left +32))
+ (wrap (n/+ (|> high frac-to-int int-to-nat (bit;shift-left +32))
(|> low frac-to-int int-to-nat))))))
(struct: #hidden _ (Codec JSON Int)
@@ -157,8 +157,8 @@
(list;enumerate members))))))))))
(do @
[g!encoders (poly;tuple (p;many Codec<JSON,?>//encode))
- #let [g!members (|> (list;size g!encoders) n.dec
- (list;n.range +0)
+ #let [g!members (|> (list;size g!encoders) n/dec
+ (list;n/range +0)
(list/map (|>. nat/encode code;local-symbol)))]]
(wrap (` (: (~ (@JSON//encode inputT))
(function [[(~@ g!members)]]
diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux
index 6424ff0fc..bc3369f86 100644
--- a/stdlib/source/lux/macro/syntax.lux
+++ b/stdlib/source/lux/macro/syntax.lux
@@ -92,18 +92,6 @@
_
(#E;Error "There are no tokens to parse!"))))
-(do-template [<name> <comp> <error>]
- [(def: #export <name>
- (Syntax Int)
- (do p;Monad<Parser>
- [n int
- _ (p;assert <error> (<comp> 0 n))]
- (wrap n)))]
-
- [pos-int i.> "Expected a positive integer: N > 0"]
- [neg-int i.< "Expected a negative integer: N < 0"]
- )
-
(do-template [<name> <tag> <desc>]
[(def: #export <name>
{#;doc (code;text ($_ text/compose "Parse a local " <desc> " (a " <desc> " that has no module prefix)."))}
diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux
index 700bc9919..4f4270c74 100644
--- a/stdlib/source/lux/math.lux
+++ b/stdlib/source/lux/math.lux
@@ -58,20 +58,20 @@
)
(def: #export (log' base input)
- (f./ (log base)
+ (f// (log base)
(log input)))
(def: #export (factorial n)
(-> Nat Nat)
(loop [acc +1
n n]
- (if (n.<= +1 n)
+ (if (n/<= +1 n)
acc
- (recur (n.* n acc) (n.dec n)))))
+ (recur (n/* n acc) (n/dec n)))))
(def: #export (hypotenuse catA catB)
(-> Frac Frac Frac)
- (root2 (f.+ (pow 2.0 catA)
+ (root2 (f/+ (pow 2.0 catA)
(pow 2.0 catB))))
(def: #export (gcd a b)
@@ -79,7 +79,7 @@
(-> Nat Nat Nat)
(case b
+0 a
- _ (gcd b (n.% b a))))
+ _ (gcd b (n/% b a))))
(def: #export (lcm x y)
{#;doc "Least Common Multiple."}
@@ -89,7 +89,7 @@
+0
_
- (|> x (n./ (gcd x y)) (n.* y))
+ (|> x (n// (gcd x y)) (n/* y))
))
## [Syntax]
@@ -157,12 +157,12 @@
(syntax: #export (infix [expr infix^])
{#;doc (doc "Infix math syntax."
- (infix [x i.* 10])
- (infix [[x i.+ y] i.* [x i.- y]])
- (infix [sin [x i.+ y]])
- (infix [[x n.< y] and [y n.< z]])
- (infix [#and x n.< y n.< z])
- (infix [(n.* +3 +9) gcd +450])
+ (infix [x i/* 10])
+ (infix [[x i/+ y] i/* [x i/- y]])
+ (infix [sin [x i/+ y]])
+ (infix [[x n/< y] and [y n/< z]])
+ (infix [#and x n/< y n/< z])
+ (infix [(n/* +3 +9) gcd +450])
"The rules for infix syntax are simple."
"If you want your binary function to work well with it."
diff --git a/stdlib/source/lux/math/logic/continuous.lux b/stdlib/source/lux/math/logic/continuous.lux
index 0546cb46c..0b385dae2 100644
--- a/stdlib/source/lux/math/logic/continuous.lux
+++ b/stdlib/source/lux/math/logic/continuous.lux
@@ -10,13 +10,13 @@
(-> Deg Deg Deg)
<chooser>)]
- [~and d.min]
- [~or d.max]
+ [~and d/min]
+ [~or d/max]
)
(def: #export (~not input)
(-> Deg Deg)
- (d.- input ~true))
+ (d/- input ~true))
(def: #export (~implies consequent antecedent)
(-> Deg Deg Deg)
@@ -26,9 +26,9 @@
(def: #export (includes~ sub super)
(-> Deg Deg Deg)
(let [-sub (~not sub)
- sum (d.+ -sub super)
- no-overflow? (and (d.>= -sub sum)
- (d.>= super sum))]
+ sum (d/+ -sub super)
+ no-overflow? (and (d/>= -sub sum)
+ (d/>= super sum))]
(if no-overflow?
sum
~true)))
diff --git a/stdlib/source/lux/math/logic/fuzzy.lux b/stdlib/source/lux/math/logic/fuzzy.lux
index 6183293a8..ba8da7d40 100644
--- a/stdlib/source/lux/math/logic/fuzzy.lux
+++ b/stdlib/source/lux/math/logic/fuzzy.lux
@@ -81,8 +81,8 @@
(<ascending> from to)
(<descending> from to)))]
- [d.ascending d.descending d.gradient Deg d.< d.> d.<= d.>= d.- d./ id]
- [f.ascending f.descending f.gradient Frac f.< f.> f.<= f.>= f.- f./ frac-to-deg]
+ [d/ascending d/descending d/gradient Deg d/< d/> d/<= d/>= d/- d// id]
+ [f/ascending f/descending f/gradient Frac f/< f/> f/<= f/>= f/- f// frac-to-deg]
)
(do-template [<triangle> <trapezoid> <type> <ascending> <descending> <lt>]
@@ -106,21 +106,21 @@
_
(undefined)))]
- [d.triangle d.trapezoid Deg d.ascending d.descending d.<]
- [f.triangle f.trapezoid Frac f.ascending f.descending f.<]
+ [d/triangle d/trapezoid Deg d/ascending d/descending d/<]
+ [f/triangle f/trapezoid Frac f/ascending f/descending f/<]
)
(def: #export (gaussian deviation center)
(-> Frac Frac (Fuzzy Frac))
(function [elem]
- (let [scale (|> deviation (math;pow 2.0) (f.* 2.0))
+ (let [scale (|> deviation (math;pow 2.0) (f/* 2.0))
membership (|> elem
- (f.- center)
+ (f/- center)
(math;pow 2.0)
- (f.* -1.0)
- (f./ scale)
+ (f/* -1.0)
+ (f// scale)
math;exp)]
- (if (f.= 1.0 membership)
+ (if (f/= 1.0 membership)
&;~true
(frac-to-deg membership)))))
@@ -128,14 +128,14 @@
(All [a] (-> Deg (Fuzzy a) (Fuzzy a)))
(function [elem]
(let [membership (set elem)]
- (if (d.> treshold membership)
- (|> membership (d.- treshold) (d.* &;~true))
+ (if (d/> treshold membership)
+ (|> membership (d/- treshold) (d/* &;~true))
&;~false))))
(def: #export (to-predicate treshold set)
(All [a] (-> Deg (Fuzzy a) (-> a Bool)))
(function [elem]
- (d.> treshold (set elem))))
+ (d/> treshold (set elem))))
(type: #export (Fuzzy2 a)
(-> a [Deg Deg]))
@@ -145,6 +145,6 @@
(function [elem]
(let [l-deg (lower elem)
u-deg (upper elem)]
- [(d.min l-deg
+ [(d/min l-deg
u-deg)
u-deg])))
diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux
index 90ee2c97b..e8b552b1c 100644
--- a/stdlib/source/lux/math/random.lux
+++ b/stdlib/source/lux/math/random.lux
@@ -69,7 +69,7 @@
(function [prng]
(let [[prng left] (prng [])
[prng right] (prng [])]
- [prng (n.+ (bit;shift-left +32 left)
+ [prng (n/+ (bit;shift-left +32 left)
right)])))
(def: #export int
@@ -77,20 +77,20 @@
(function [prng]
(let [[prng left] (prng [])
[prng right] (prng [])]
- [prng (nat-to-int (n.+ (bit;shift-left +32 left)
+ [prng (nat-to-int (n/+ (bit;shift-left +32 left)
right))])))
(def: #export bool
(Random Bool)
(function [prng]
(let [[prng output] (prng [])]
- [prng (|> output (bit;and +1) (n.= +1))])))
+ [prng (|> output (bit;and +1) (n/= +1))])))
(def: (bits n)
(-> Nat (Random Nat))
(function [prng]
(let [[prng output] (prng [])]
- [prng (bit;shift-right (n.- n +64) output)])))
+ [prng (bit;shift-right (n/- n +64) output)])))
(def: #export frac
(Random Frac)
@@ -98,10 +98,10 @@
[left (bits +26)
right (bits +27)]
(wrap (|> right
- (n.+ (bit;shift-left +27 left))
+ (n/+ (bit;shift-left +27 left))
nat-to-int
int-to-frac
- (f./ (|> +1 (bit;shift-left +53) nat-to-int int-to-frac))))))
+ (f// (|> +1 (bit;shift-left +53) nat-to-int int-to-frac))))))
(def: #export deg
(Random Deg)
@@ -109,11 +109,11 @@
(def: #export (text' char-gen size)
(-> (Random Nat) Nat (Random Text))
- (if (n.= +0 size)
+ (if (n/= +0 size)
(:: Monad<Random> wrap "")
(do Monad<Random>
[x char-gen
- xs (text' char-gen (n.dec size))]
+ xs (text' char-gen (n/dec size))]
(wrap (text/compose (text;from-code x) xs)))))
(type: Char-Range [Nat Nat])
@@ -135,61 +135,61 @@
(def: (within? [from to] char)
(-> Char-Range Nat Bool)
- (and (n.>= from char) (n.<= to char)))
+ (and (n/>= from char) (n/<= to char)))
-(def: unicode-ceiling (n.inc (product;right CJK-Compatibility-Ideographs-Supplement)))
+(def: unicode-ceiling (n/inc (product;right CJK-Compatibility-Ideographs-Supplement)))
(def: #export unicode
(Random Nat)
(|> ;;nat
- (:: Monad<Random> map (n.% unicode-ceiling))
+ (:: Monad<Random> map (n/% unicode-ceiling))
(;;filter (function [raw]
## From "Basic Latin" to "Syriac"
- (or (n.<= (hex "+074F") raw)
+ (or (n/<= (hex "+074F") raw)
(within? Thaana raw)
## From "Devanagari" to "Ethiopic"
- (and (n.>= (hex "+0900") raw)
- (n.<= (hex "+137F") raw))
+ (and (n/>= (hex "+0900") raw)
+ (n/<= (hex "+137F") raw))
## From "Cherokee" to "Mongolian"
- (and (n.>= (hex "+13A0") raw)
- (n.<= (hex "+18AF") raw))
+ (and (n/>= (hex "+13A0") raw)
+ (n/<= (hex "+18AF") raw))
## From "Limbu" to "Tai Le"
- (and (n.>= (hex "+1900") raw)
- (n.<= (hex "+197F") raw))
+ (and (n/>= (hex "+1900") raw)
+ (n/<= (hex "+197F") raw))
(within? Khmer-Symbols raw)
(within? Phonetic-Extensions raw)
## From "Latin Extended Additional" to "Miscellaneous Symbols and Arrows"
- (and (n.>= (hex "+1E00") raw)
- (n.<= (hex "+2BFF") raw))
+ (and (n/>= (hex "+1E00") raw)
+ (n/<= (hex "+2BFF") raw))
## From "CJK Radicals Supplement" to "Kangxi Radicals"
- (and (n.>= (hex "+2E80") raw)
- (n.<= (hex "+2FDF") raw))
+ (and (n/>= (hex "+2E80") raw)
+ (n/<= (hex "+2FDF") raw))
## From "Ideographic Description Characters" to "Bopomofo Extended"
- (and (n.>= (hex "+2FF0") raw)
- (n.<= (hex "+31BF") raw))
+ (and (n/>= (hex "+2FF0") raw)
+ (n/<= (hex "+31BF") raw))
## From "Katakana Phonetic Extensions" to "CJK Unified Ideographs"
- (and (n.>= (hex "+31F0") raw)
- (n.<= (hex "+9FAF") raw))
+ (and (n/>= (hex "+31F0") raw)
+ (n/<= (hex "+9FAF") raw))
## From "Yi Syllables" to "Yi Radicals"
- (and (n.>= (hex "+A000") raw)
- (n.<= (hex "+A4CF") raw))
+ (and (n/>= (hex "+A000") raw)
+ (n/<= (hex "+A4CF") raw))
(within? Hangul-Syllables raw)
## From "CJK Compatibility Ideographs" to "Arabic Presentation Forms-A"
- (and (n.>= (hex "+F900") raw)
- (n.<= (hex "+FDFF") raw))
+ (and (n/>= (hex "+F900") raw)
+ (n/<= (hex "+FDFF") raw))
## From "Combining Half Marks" to "Halfwidth and Fullwidth Forms"
- (and (n.>= (hex "+FE20") raw)
- (n.<= (hex "+FFEF") raw))
+ (and (n/>= (hex "+FE20") raw)
+ (n/<= (hex "+FFEF") raw))
## From "Linear B Syllabary" to "Aegean Numbers"
- (and (n.>= (hex "+10000") raw)
- (n.<= (hex "+1013F") raw))
+ (and (n/>= (hex "+10000") raw)
+ (n/<= (hex "+1013F") raw))
## From "Old Italic" to "Osmanya"
- (and (n.>= (hex "+10300") raw)
- (n.<= (hex "+104AF") raw))
+ (and (n/>= (hex "+10300") raw)
+ (n/<= (hex "+104AF") raw))
(within? Cypriot-Syllabary raw)
## From "Byzantine Musical Symbols" to "Musical Symbols"
- (and (n.>= (hex "+1D000") raw)
- (n.<= (hex "+1D1FF") raw))
+ (and (n/>= (hex "+1D000") raw)
+ (n/<= (hex "+1D1FF") raw))
(within? Tai-Xuan-Jing-Symbols raw)
(within? Mathematical-Alphanumeric-Symbols raw)
(within? CJK-Unified-Ideographs-Extension-B raw)
@@ -262,10 +262,10 @@
(do-template [<name> <type> <zero> <plus>]
[(def: #export (<name> size value-gen)
(All [a] (-> Nat (Random a) (Random (<type> a))))
- (if (n.> +0 size)
+ (if (n/> +0 size)
(do Monad<Random>
[x value-gen
- xs (<name> (n.dec size) value-gen)]
+ xs (<name> (n/dec size) value-gen)]
(wrap (<plus> x xs)))
(:: Monad<Random> wrap <zero>)))]
@@ -287,29 +287,29 @@
(def: #export (set Hash<a> size value-gen)
(All [a] (-> (Hash a) Nat (Random a) (Random (Set a))))
- (if (n.> +0 size)
+ (if (n/> +0 size)
(do Monad<Random>
- [xs (set Hash<a> (n.dec size) value-gen)]
+ [xs (set Hash<a> (n/dec size) value-gen)]
(loop [_ []]
(do @
[x value-gen
#let [xs+ (set;add x xs)]]
- (if (n.= size (set;size xs+))
+ (if (n/= size (set;size xs+))
(wrap xs+)
(recur [])))))
(:: Monad<Random> wrap (set;new Hash<a>))))
(def: #export (dict Hash<a> size key-gen value-gen)
(All [k v] (-> (Hash k) Nat (Random k) (Random v) (Random (Dict k v))))
- (if (n.> +0 size)
+ (if (n/> +0 size)
(do Monad<Random>
- [kv (dict Hash<a> (n.dec size) key-gen value-gen)]
+ [kv (dict Hash<a> (n/dec size) key-gen value-gen)]
(loop [_ []]
(do @
[k key-gen
v value-gen
#let [kv+ (dict;put k v kv)]]
- (if (n.= size (dict;size kv+))
+ (if (n/= size (dict;size kv+))
(wrap kv+)
(recur [])))))
(:: Monad<Random> wrap (dict;new Hash<a>))))
@@ -318,9 +318,6 @@
(All [a] (-> PRNG (Random a) [PRNG a]))
(calc prng))
-## PCG32 http://www.pcg-random.org/
-## Based on this Java implementation: https://github.com/alexeyr/pcg-java
-
(def: pcg-32-magic-mult Nat +6364136223846793005)
(def: #export (pcg-32 [inc seed])
@@ -329,20 +326,19 @@
For more information, please see: http://www.pcg-random.org/"}
(-> [Nat Nat] PRNG)
(function [_]
- (let [seed' (|> seed (n.* pcg-32-magic-mult) (n.+ inc))
+ (let [seed' (|> seed (n/* pcg-32-magic-mult) (n/+ inc))
xor-shifted (|> seed (bit;shift-right +18) (bit;xor seed) (bit;shift-right +27))
rot (|> seed (bit;shift-right +59))]
[(pcg-32 [inc seed']) (bit;rotate-right rot xor-shifted)]
)))
-## Xoroshiro128+ http://xoroshiro.di.unimi.it/
(def: #export (xoroshiro-128+ [s0 s1])
{#;doc "An implementation of the Xoroshiro128+ algorithm.
For more information, please see: http://xoroshiro.di.unimi.it/"}
(-> [Nat Nat] PRNG)
(function [_]
- (let [result (n.+ s0 s1)
+ (let [result (n/+ s0 s1)
s01 (bit;xor s0 s1)
s0' (|> (bit;rotate-left +55 s0)
(bit;xor s01)
@@ -365,9 +361,9 @@
(function [idx vec]
(do Monad<Random>
[rand nat]
- (wrap (swap idx (n.% _size rand) vec))))
+ (wrap (swap idx (n/% _size rand) vec))))
sequence
- (list;n.range +0 (n.dec _size)))]
+ (list;n/range +0 (n/dec _size)))]
(|> _shuffle
(run (pcg-32 [+123 seed]))
product;right)))
diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux
index f8cfa9871..10672afaf 100644
--- a/stdlib/source/lux/test.lux
+++ b/stdlib/source/lux/test.lux
@@ -47,7 +47,7 @@
(def: (add-counters [s f] [ts tf])
(-> Counters Counters Counters)
- [(n.+ s ts) (n.+ f tf)])
+ [(n/+ s ts) (n/+ f tf)])
(def: #export (fail message)
(All [a] (-> Text Test))
@@ -91,7 +91,7 @@
(def: failed?
(-> Counters Bool)
- (|>. product;right (n.> +0)))
+ (|>. product;right (n/> +0)))
(def: #export (seed value test)
(-> Seed Test Test)
@@ -102,10 +102,10 @@
(def: #export (times amount test)
(-> Nat Test Test)
- (cond (n.= +0 amount)
+ (cond (n/= +0 amount)
(fail "Cannot try a test 0 times.")
- (n.= +1 amount)
+ (n/= +1 amount)
test
## else
@@ -117,7 +117,7 @@
[[counters documentation] instance]
(if (failed? counters)
(wrap [counters (format "Failed with this seed: " (%n seed) "\n" documentation)])
- (product;right (r;run prng' (times (n.dec amount) test)))))])))))
+ (product;right (r;run prng' (times (n/dec amount) test)))))])))))
## [Syntax]
(def: #hidden _code/text_ code;text)
@@ -127,11 +127,11 @@
(context: "Simple macros and constructs"
($_ seq
(test "Can write easy loops for iterative programming."
- (i.= 1000
+ (i/= 1000
(loop [counter 0
value 1]
- (if (i.< 3 counter)
- (recur (i.inc counter) (i.* 10 value))
+ (if (i/< 3 counter)
+ (recur (i/inc counter) (i/* 10 value))
value))))
(test "Can create lists easily through macros."
@@ -238,20 +238,20 @@
(~ g!total-failures) +0]
(~@ (list/join (list/map (function [group]
(list (` [(~ g!successes) (~ g!failures)]) (` (run' (list (~@ group))))
- (' #let) (` [(~ g!total-successes) (n.+ (~ g!successes) (~ g!total-successes))
- (~ g!total-failures) (n.+ (~ g!failures) (~ g!total-failures))])))
+ (' #let) (` [(~ g!total-successes) (n/+ (~ g!successes) (~ g!total-successes))
+ (~ g!total-failures) (n/+ (~ g!failures) (~ g!total-failures))])))
groups)))]
(exec (log! ($_ _composeT_
"Test-suite finished."
"\n"
(_%i_ (nat-to-int (~ g!total-successes)))
" out of "
- (_%i_ (nat-to-int (n.+ (~ g!total-failures)
+ (_%i_ (nat-to-int (n/+ (~ g!total-failures)
(~ g!total-successes))))
" tests passed."
"\n"
(_%i_ (nat-to-int (~ g!total-failures))) " tests failed."))
- (promise;future (if (n.> +0 (~ g!total-failures))
+ (promise;future (if (n/> +0 (~ g!total-failures))
;;die
;;exit))))
[])))))))))
diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux
index 5b124a669..36719b45f 100644
--- a/stdlib/source/lux/time/date.lux
+++ b/stdlib/source/lux/time/date.lux
@@ -73,10 +73,10 @@
[(def: (<name> reference sample)
(<comp> (month-to-nat reference) (month-to-nat sample)))]
- [< n.<]
- [<= n.<=]
- [> n.>]
- [>= n.>=]
+ [< n/<]
+ [<= n/<=]
+ [> n/>]
+ [>= n/>=]
))
(struct: #export _ (Enum Month)
@@ -153,10 +153,10 @@
[(def: (<name> reference sample)
(<comp> (day-to-nat reference) (day-to-nat sample)))]
- [< n.<]
- [<= n.<=]
- [> n.>]
- [>= n.>=]
+ [< n/<]
+ [<= n/<=]
+ [> n/>]
+ [>= n/>=]
))
(struct: #export _ (Enum Day)
@@ -187,22 +187,22 @@
(struct: #export _ (Eq Date)
(def: (= reference sample)
- (and (i.= (get@ #year reference)
+ (and (i/= (get@ #year reference)
(get@ #year sample))
(:: Eq<Month> =
(get@ #month reference)
(get@ #month sample))
- (n.= (get@ #day reference)
+ (n/= (get@ #day reference)
(get@ #day sample)))))
(def: (date.< reference sample)
(-> Date Date Bool)
- (or (i.< (get@ #year reference)
+ (or (i/< (get@ #year reference)
(get@ #year sample))
(:: Order<Month> <
(get@ #month reference)
(get@ #month sample))
- (n.< (get@ #day reference)
+ (n/< (get@ #day reference)
(get@ #day sample))))
(struct: #export _ (Order Date)
@@ -220,7 +220,7 @@
## Based on this: https://stackoverflow.com/a/42936293/6823464
(def: (pad value)
(-> Int Text)
- (if (i.< 10 value)
+ (if (i/< 10 value)
(text/compose "0" (int/encode value))
(int/encode value)))
@@ -228,7 +228,7 @@
(-> Date Text)
($_ text/compose
(int/encode year) "-"
- (pad (|> month month-to-nat n.inc nat-to-int)) "-"
+ (pad (|> month month-to-nat n/inc nat-to-int)) "-"
(pad (|> day nat-to-int))))
(def: lex-year
@@ -239,7 +239,7 @@
#let [signum (case sign?
#;None 1
(#;Some _) -1)]]
- (wrap (i.* signum raw-year))))
+ (wrap (i/* signum raw-year))))
(def: lex-section
(l;Lexer Int)
@@ -247,9 +247,9 @@
(def: (leap-years year)
(-> Int Int)
- (|> (i./ 4 year)
- (i.- (i./ 100 year))
- (i.+ (i./ 400 year))))
+ (|> (i// 4 year)
+ (i/- (i// 100 year))
+ (i/+ (i// 400 year))))
(def: normal-months
(Sequence Nat)
@@ -260,11 +260,11 @@
(def: leap-year-months
(Sequence Nat)
- (sequence;update [+1] n.inc normal-months))
+ (sequence;update [+1] n/inc normal-months))
(def: (divisible? factor input)
(-> Int Int Bool)
- (|> input (i.% factor) (i.= 0)))
+ (|> input (i/% factor) (i/= 0)))
(def: (leap-year? year)
(-> Int Bool)
@@ -280,19 +280,19 @@
_ (l;this "-")
utc-month lex-section
_ (p;assert "Invalid month."
- (and (i.>= 1 utc-month)
- (i.<= 12 utc-month)))
+ (and (i/>= 1 utc-month)
+ (i/<= 12 utc-month)))
#let [months (if (leap-year? utc-year)
leap-year-months
normal-months)
month-days (|> months
- (sequence;nth (int-to-nat (i.dec utc-month)))
+ (sequence;nth (int-to-nat (i/dec utc-month)))
maybe;assume)]
_ (l;this "-")
utc-day lex-section
_ (p;assert "Invalid day."
- (and (i.>= 1 utc-day)
- (i.<= (nat-to-int month-days) utc-day)))]
+ (and (i/>= 1 utc-day)
+ (i/<= (nat-to-int month-days) utc-day)))]
(wrap {#year utc-year
#month (case utc-month
1 #January
diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux
index 283b48c91..642550bc3 100644
--- a/stdlib/source/lux/time/duration.lux
+++ b/stdlib/source/lux/time/duration.lux
@@ -28,21 +28,21 @@
(-> Duration Duration Duration)
(@opaque (<op> (@repr param) (@repr subject))))]
- [merge i.+]
- [frame i.%]
+ [merge i/+]
+ [frame i/%]
)
(def: #export (scale scalar duration)
(-> Int Duration Duration)
- (@opaque (i.* scalar (@repr duration))))
+ (@opaque (i/* scalar (@repr duration))))
(def: #export (query param subject)
(-> Duration Duration Int)
- (i./ (@repr param) (@repr subject)))
+ (i// (@repr param) (@repr subject)))
(struct: #export _ (Eq Duration)
(def: (= param subject)
- (i.= (@repr param) (@repr subject))))
+ (i/= (@repr param) (@repr subject))))
(struct: #export _ (Order Duration)
(def: eq Eq<Duration>)
@@ -50,10 +50,10 @@
[(def: (<name> param subject)
(<op> (@repr param) (@repr subject)))]
- [< i.<]
- [<= i.<=]
- [> i.>]
- [>= i.>=]
+ [< i/<]
+ [<= i/<=]
+ [> i/>]
+ [>= i/>=]
))
(do-template [<name> <op>]
@@ -61,9 +61,9 @@
(-> Duration Bool)
(<op> 0 (@repr duration)))]
- [positive? i.>]
- [negative? i.<]
- [neutral? i.=])
+ [positive? i/>]
+ [negative? i/<]
+ [neutral? i/=])
)
(def: #export empty Duration (from-millis 0))
@@ -94,11 +94,11 @@
millis (to-millis time-left)]
($_ text/compose
(if signed? "-" "")
- (if (i.= 0 days) "" (text/compose (int/encode days) "D"))
- (if (i.= 0 hours) "" (text/compose (int/encode hours) "h"))
- (if (i.= 0 minutes) "" (text/compose (int/encode minutes) "m"))
- (if (i.= 0 seconds) "" (text/compose (int/encode seconds) "s"))
- (if (i.= 0 millis) "" (text/compose (int/encode millis) "ms"))
+ (if (i/= 0 days) "" (text/compose (int/encode days) "D"))
+ (if (i/= 0 hours) "" (text/compose (int/encode hours) "h"))
+ (if (i/= 0 minutes) "" (text/compose (int/encode minutes) "m"))
+ (if (i/= 0 seconds) "" (text/compose (int/encode seconds) "s"))
+ (if (i/= 0 millis) "" (text/compose (int/encode millis) "ms"))
))))
(def: (lex-section suffix)
@@ -111,21 +111,21 @@
(l;Lexer Duration)
(do p;Monad<Parser>
[signed? (l;this? "-")
- #let [sign (function [raw] (if signed? (i.* -1 raw) raw))]
+ #let [sign (function [raw] (if signed? (i/* -1 raw) raw))]
utc-day (lex-section "D")
utc-hour (lex-section "h")
utc-minute (lex-section "m")
_ (p;assert "Invalid minute."
- (and (i.>= 0 utc-minute)
- (i.<= 59 utc-minute)))
+ (and (i/>= 0 utc-minute)
+ (i/<= 59 utc-minute)))
utc-second (lex-section "s")
_ (p;assert "Invalid second."
- (and (i.>= 0 utc-second)
- (i.<= 59 utc-second)))
+ (and (i/>= 0 utc-second)
+ (i/<= 59 utc-second)))
utc-millis (lex-section "ms")
_ (p;assert "Invalid milli-seconds."
- (and (i.>= 0 utc-millis)
- (i.<= 999 utc-millis)))]
+ (and (i/>= 0 utc-millis)
+ (i/<= 999 utc-millis)))]
(wrap (|> empty
(merge (scale (sign utc-day) day))
(merge (scale (sign utc-hour) hour))
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index 83b415024..2429d0bee 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -32,11 +32,11 @@
(def: #export (span from to)
(-> Instant Instant duration;Duration)
- (duration;from-millis (i.- (@repr from) (@repr to))))
+ (duration;from-millis (i/- (@repr from) (@repr to))))
(def: #export (shift duration instant)
(-> duration;Duration Instant Instant)
- (@opaque (i.+ (duration;to-millis duration) (@repr instant))))
+ (@opaque (i/+ (duration;to-millis duration) (@repr instant))))
(def: #export (relative instant)
(-> Instant duration;Duration)
@@ -77,7 +77,7 @@
## Codec::encode
(def: (divisible? factor input)
(-> Int Int Bool)
- (|> input (i.% factor) (i.= 0)))
+ (|> input (i/% factor) (i/= 0)))
(def: (leap-year? year)
(-> Int Bool)
@@ -94,11 +94,11 @@
(let [year (if (leap-year? reference)
duration;leap-year
duration;normal-year)]
- (if (i.= 0 (duration;query year time-left))
+ (if (i/= 0 (duration;query year time-left))
[reference time-left]
(if (duration/>= duration;empty time-left)
- (recur (i.inc reference) (duration;merge (duration;scale -1 year) time-left))
- (recur (i.dec reference) (duration;merge year time-left)))
+ (recur (i/inc reference) (duration;merge (duration;scale -1 year) time-left))
+ (recur (i/dec reference) (duration;merge year time-left)))
))))
(def: normal-months
@@ -110,29 +110,29 @@
(def: leap-year-months
(Sequence Nat)
- (sequence;update [+1] n.inc normal-months))
+ (sequence;update [+1] n/inc normal-months))
(def: (find-month months time)
(-> (Sequence Nat) duration;Duration [Nat duration;Duration])
(if (duration/>= duration;empty time)
(sequence/fold (function [month-days [current-month time-left]]
(let [month-duration (duration;scale (nat-to-int month-days) duration;day)]
- (if (i.= 0 (duration;query month-duration time-left))
+ (if (i/= 0 (duration;query month-duration time-left))
[current-month time-left]
- [(n.inc current-month) (duration;merge (duration;scale -1 month-duration) time-left)])))
+ [(n/inc current-month) (duration;merge (duration;scale -1 month-duration) time-left)])))
[+0 time]
months)
(sequence/fold (function [month-days [current-month time-left]]
(let [month-duration (duration;scale (nat-to-int month-days) duration;day)]
- (if (i.= 0 (duration;query month-duration time-left))
+ (if (i/= 0 (duration;query month-duration time-left))
[current-month time-left]
- [(n.dec current-month) (duration;merge month-duration time-left)])))
+ [(n/dec current-month) (duration;merge month-duration time-left)])))
[+11 time]
(sequence;reverse months))))
(def: (pad value)
(-> Int Text)
- (if (i.< 10 value)
+ (if (i/< 10 value)
(text/compose "0" (int/encode value))
(int/encode value)))
@@ -144,10 +144,10 @@
(def: (encode-millis millis)
(-> Int Text)
- (cond (i.= 0 millis) ""
- (i.< 10 millis) ($_ text/compose ".00" (int/encode millis))
- (i.< 100 millis) ($_ text/compose ".0" (int/encode millis))
- ## (i.< 1_000 millis)
+ (cond (i/= 0 millis) ""
+ (i/< 10 millis) ($_ text/compose ".00" (int/encode millis))
+ (i/< 100 millis) ($_ text/compose ".0" (int/encode millis))
+ ## (i/< 1_000 millis)
($_ text/compose "." (int/encode millis))))
(def: seconds-per-day Int (duration;query duration;second duration;day))
@@ -157,36 +157,36 @@
(-> Instant [[Int Int Int] duration;Duration])
(let [offset (relative instant)
seconds (duration;query duration;second offset)
- z (|> seconds (i./ seconds-per-day) (i.+ days-up-to-epoch))
- era (i./ 146097
- (if (i.>= 0 z)
+ z (|> seconds (i// seconds-per-day) (i/+ days-up-to-epoch))
+ era (i// 146097
+ (if (i/>= 0 z)
z
- (i.- 146096 z)))
- days-of-era (|> z (i.- (i.* 146097 era)))
+ (i/- 146096 z)))
+ days-of-era (|> z (i/- (i/* 146097 era)))
years-of-era (|> days-of-era
- (i.- (i./ 1460 days-of-era))
- (i.+ (i./ 36524 days-of-era))
- (i.- (i./ 146096 days-of-era))
- (i./ 365))
- year (|> years-of-era (i.+ (i.* 400 era)))
+ (i/- (i// 1460 days-of-era))
+ (i/+ (i// 36524 days-of-era))
+ (i/- (i// 146096 days-of-era))
+ (i// 365))
+ year (|> years-of-era (i/+ (i/* 400 era)))
days-of-year (|> days-of-era
- (i.- (|> (i.* 365 years-of-era)
- (i.+ (i./ 4 years-of-era))
- (i.- (i./ 100 years-of-era)))))
+ (i/- (|> (i/* 365 years-of-era)
+ (i/+ (i// 4 years-of-era))
+ (i/- (i// 100 years-of-era)))))
day-time (duration;frame duration;day offset)
days-of-year (if (duration/>= duration;empty day-time)
days-of-year
- (i.dec days-of-year))
- mp (|> days-of-year (i.* 5) (i.+ 2) (i./ 153))
+ (i/dec days-of-year))
+ mp (|> days-of-year (i/* 5) (i/+ 2) (i// 153))
day (|> days-of-year
- (i.- (|> mp (i.* 153) (i.+ 2) (i./ 5)))
- (i.+ 1))
+ (i/- (|> mp (i/* 153) (i/+ 2) (i// 5)))
+ (i/+ 1))
month (|> mp
- (i.+ (if (i.< 10 mp)
+ (i/+ (if (i/< 10 mp)
3
-9)))
- year (if (i.<= 2 month)
- (i.inc year)
+ year (if (i/<= 2 month)
+ (i/inc year)
year)]
[[year month day]
day-time]))
@@ -219,7 +219,7 @@
#let [signum (case sign?
#;None 1
(#;Some _) -1)]]
- (wrap (i.* signum raw-year))))
+ (wrap (i/* signum raw-year))))
(def: lex-section
(l;Lexer Int)
@@ -234,9 +234,9 @@
(def: (leap-years year)
(-> Int Int)
- (|> (i./ 4 year)
- (i.- (i./ 100 year))
- (i.+ (i./ 400 year))))
+ (|> (i// 4 year)
+ (i/- (i// 100 year))
+ (i/+ (i// 400 year))))
## Based on: https://stackoverflow.com/a/3309340/6823464
(def: lex-instant
@@ -246,48 +246,48 @@
_ (l;this "-")
utc-month lex-section
_ (p;assert "Invalid month."
- (and (i.>= 1 utc-month)
- (i.<= 12 utc-month)))
+ (and (i/>= 1 utc-month)
+ (i/<= 12 utc-month)))
#let [months (if (leap-year? utc-year)
leap-year-months
normal-months)
month-days (|> months
- (sequence;nth (int-to-nat (i.dec utc-month)))
+ (sequence;nth (int-to-nat (i/dec utc-month)))
maybe;assume)]
_ (l;this "-")
utc-day lex-section
_ (p;assert "Invalid day."
- (and (i.>= 1 utc-day)
- (i.<= (nat-to-int month-days) utc-day)))
+ (and (i/>= 1 utc-day)
+ (i/<= (nat-to-int month-days) utc-day)))
_ (l;this "T")
utc-hour lex-section
_ (p;assert "Invalid hour."
- (and (i.>= 0 utc-hour)
- (i.<= 23 utc-hour)))
+ (and (i/>= 0 utc-hour)
+ (i/<= 23 utc-hour)))
_ (l;this ":")
utc-minute lex-section
_ (p;assert "Invalid minute."
- (and (i.>= 0 utc-minute)
- (i.<= 59 utc-minute)))
+ (and (i/>= 0 utc-minute)
+ (i/<= 59 utc-minute)))
_ (l;this ":")
utc-second lex-section
_ (p;assert "Invalid second."
- (and (i.>= 0 utc-second)
- (i.<= 59 utc-second)))
+ (and (i/>= 0 utc-second)
+ (i/<= 59 utc-second)))
utc-millis lex-millis
_ (l;this "Z")
- #let [years-since-epoch (i.- epoch-year utc-year)
- previous-leap-days (i.- (leap-years epoch-year)
- (leap-years (i.dec utc-year)))
- year-days-so-far (|> (i.* 365 years-since-epoch)
- (i.+ previous-leap-days))
+ #let [years-since-epoch (i/- epoch-year utc-year)
+ previous-leap-days (i/- (leap-years epoch-year)
+ (leap-years (i/dec utc-year)))
+ year-days-so-far (|> (i/* 365 years-since-epoch)
+ (i/+ previous-leap-days))
month-days-so-far (|> months
sequence;to-list
- (list;take (int-to-nat (i.dec utc-month)))
- (L/fold n.+ +0))
+ (list;take (int-to-nat (i/dec utc-month)))
+ (L/fold n/+ +0))
total-days (|> year-days-so-far
- (i.+ (nat-to-int month-days-so-far))
- (i.+ (i.dec utc-day)))]]
+ (i/+ (nat-to-int month-days-so-far))
+ (i/+ (i/dec utc-day)))]]
(wrap (|> epoch
(shift (duration;scale total-days duration;day))
(shift (duration;scale utc-hour duration;hour))
@@ -315,7 +315,7 @@
(-> Instant date;Date)
(let [[[year month day] _] (extract-date instant)]
{#date;year year
- #date;month (case (i.dec month)
+ #date;month (case (i/dec month)
0 #date;January
1 #date;February
2 #date;March
@@ -343,14 +343,14 @@
day-time (duration;frame duration;day offset)
days (if (and (duration;negative? offset)
(not (duration;neutral? day-time)))
- (i.dec days)
+ (i/dec days)
days)
## 1970/01/01 was a Thursday
y1970m0d0 4]
(case (|> y1970m0d0
- (i.+ days) (i.% 7)
+ (i/+ days) (i/% 7)
## This is done to turn negative days into positive days.
- (i.+ 7) (i.% 7))
+ (i/+ 7) (i/% 7))
0 #date;Sunday
1 #date;Monday
2 #date;Tuesday
diff --git a/stdlib/source/lux/type/implicit.lux b/stdlib/source/lux/type/implicit.lux
index e23a5c8dd..fb08f0a0b 100644
--- a/stdlib/source/lux/type/implicit.lux
+++ b/stdlib/source/lux/type/implicit.lux
@@ -20,7 +20,7 @@
(def: (find-type-var id env)
(-> Nat Type-Context (Meta Type))
- (case (list;find (|>. product;left (n.= id))
+ (case (list;find (|>. product;left (n/= id))
(get@ #;var-bindings env))
(#;Some [_ (#;Some type)])
(case type
@@ -64,12 +64,12 @@
(find-member-type idx sig-type'))
(#;Product left right)
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(:: Monad<Check> wrap left)
- (find-member-type (n.dec idx) right))
+ (find-member-type (n/dec idx) right))
_
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(:: Monad<Check> wrap sig-type)
(tc;fail (format "Cannot find member type " (%n idx) " for " (%type sig-type))))))
@@ -324,10 +324,10 @@
(::: eq;= x y)
"(List Nat) equality"
(::: =
- (list;n.range +1 +10)
- (list;n.range +1 +10))
+ (list;n/range +1 +10)
+ (list;n/range +1 +10))
"(Functor List) map"
- (::: map n.inc (list;n.range +0 +9))
+ (::: map n/inc (list;n/range +0 +9))
"Caveat emptor: You need to make sure to import the module of any structure you want to use."
"Otherwise, this macro will not find it.")}
(case args
diff --git a/stdlib/source/lux/type/object.lux b/stdlib/source/lux/type/object.lux
index a7945b41a..461e836a3 100644
--- a/stdlib/source/lux/type/object.lux
+++ b/stdlib/source/lux/type/object.lux
@@ -34,7 +34,7 @@
(do p;Monad<Parser>
[raw parser
_ (p;assert "Cannot repeat the names of type variables/parameters."
- (n.= (set;size (var-set raw))
+ (n/= (set;size (var-set raw))
(list;size raw)))]
(wrap raw)))
@@ -64,8 +64,8 @@
(if (list;empty? ancestors)
(list)
(|> (list;size ancestors)
- n.dec
- (list;n.range +0)
+ n/dec
+ (list;n/range +0)
(L/map (|>. %n (format "ancestor") code;local-symbol)))))
## [Methods]
@@ -166,7 +166,7 @@
currentT newT]
(case currentT
(#;UnivQ _ bodyT)
- (recur (n.inc depth) bodyT)
+ (recur (n/inc depth) bodyT)
(#;Function inputT outputT)
(let [[stateT+ objectT] (type;flatten-function currentT)]
@@ -182,9 +182,9 @@
typeC
size
- (|> (n.dec size)
- (list;n.range +0)
- (L/map (|>. (n.* +2) n.inc code;nat (~) #;Bound (`)))
+ (|> (n/dec size)
+ (list;n/range +0)
+ (L/map (|>. (n/* +2) n/inc code;nat (~) #;Bound (`)))
(list;zip2 (list;reverse mappings))
(L/fold (function [[mappingC boundC] genericC]
(code;replace boundC mappingC genericC))
diff --git a/stdlib/source/lux/type/unit.lux b/stdlib/source/lux/type/unit.lux
index ef8f5410a..c2a4629c0 100644
--- a/stdlib/source/lux/type/unit.lux
+++ b/stdlib/source/lux/type/unit.lux
@@ -81,10 +81,10 @@
(s;tuple (do p;Monad<Parser>
[numerator s;int
_ (p;assert (format "Numerator must be positive: " (%i numerator))
- (i.> 0 numerator))
+ (i/> 0 numerator))
denominator s;int
_ (p;assert (format "Denominator must be positive: " (%i denominator))
- (i.> 0 denominator))]
+ (i/> 0 denominator))]
(wrap [(int-to-nat numerator) (int-to-nat denominator)]))))
(syntax: #export (scale: [export csr;export]
@@ -99,13 +99,13 @@
(;;Scale (~ g!scale))
(def: (~' scale)
(|>. ;;out
- (i.* (~ (code;int (nat-to-int numerator))))
- (i./ (~ (code;int (nat-to-int denominator))))
+ (i/* (~ (code;int (nat-to-int numerator))))
+ (i// (~ (code;int (nat-to-int denominator))))
(;;in (:! ((~ g!scale) ($ +0)) []))))
(def: (~' de-scale)
(|>. ;;out
- (i.* (~ (code;int (nat-to-int denominator))))
- (i./ (~ (code;int (nat-to-int numerator))))
+ (i/* (~ (code;int (nat-to-int denominator))))
+ (i// (~ (code;int (nat-to-int numerator))))
(;;in (:! ($ +0) []))))
(def: (~' ratio)
[(~ (code;nat numerator)) (~ (code;nat denominator))])))
@@ -116,31 +116,31 @@
(All [unit] (-> (Qty unit) (Qty unit) (Qty unit)))
(|> (out subject) (<op> (out param)) (in (carrier subject))))]
- [++ i.+]
- [-- i.-]
+ [u+ i/+]
+ [u- i/-]
)
-(def: #export (// param subject)
+(def: #export (u/ param subject)
(All [p s] (-> (Qty p) (Qty s) (|> (Qty s) (Per (Qty p)))))
(function [input]
(|> (out subject)
- (i.* (out input))
- (i./ (out param))
+ (i/* (out input))
+ (i// (out param))
(in (carrier subject)))))
-(def: #export (** param subject)
+(def: #export (u* param subject)
(All [p s] (-> (Qty p) (Qty s) (Product (Qty p) (Qty s))))
(function [input]
(|> (out subject)
- (i.* (out (input param)))
+ (i/* (out (input param)))
(in (carrier subject)))))
(def: #export (re-scale from to quantity)
(All [si so u] (-> (Scale si) (Scale so) (Qty (si u)) (Qty (so u))))
(let [[numerator denominator] (|> (:: to ratio) (r;q./ (:: from ratio)))]
(|> quantity out
- (i.* (nat-to-int numerator))
- (i./ (nat-to-int denominator))
+ (i/* (nat-to-int numerator))
+ (i// (nat-to-int denominator))
(in (:! (($ +1) ($ +2)) [])))))
(scale: #export Kilo [1 1_000])
@@ -163,7 +163,7 @@
(struct: #export Eq<Unit> (All [unit] (Eq (Qty unit)))
(def: (= reference sample)
- (i.= (out reference) (out sample))))
+ (i/= (out reference) (out sample))))
(struct: #export Order<Unit> (All [unit] (Order (Qty unit)))
(def: eq Eq<Unit>)
@@ -172,12 +172,12 @@
[(def: (<name> reference sample)
(<func> (out reference) (out sample)))]
- [< i.<]
- [<= i.<=]
- [> i.>]
- [>= i.>=]))
+ [< i/<]
+ [<= i/<=]
+ [> i/>]
+ [>= i/>=]))
(struct: #export Enum<Unit> (All [unit] (Enum (Qty unit)))
(def: order Order<Unit>)
- (def: (succ qty) (|> (out qty) i.inc (in (carrier qty))))
- (def: (pred qty) (|> (out qty) i.dec (in (carrier qty)))))
+ (def: (succ qty) (|> (out qty) i/inc (in (carrier qty))))
+ (def: (pred qty) (|> (out qty) i/dec (in (carrier qty)))))
diff --git a/stdlib/source/lux/world/blob.jvm.lux b/stdlib/source/lux/world/blob.jvm.lux
index c31feb8e5..f6dcb1f6e 100644
--- a/stdlib/source/lux/world/blob.jvm.lux
+++ b/stdlib/source/lux/world/blob.jvm.lux
@@ -20,7 +20,7 @@
(def: byte-mask
Nat
- (|> +1 (bit;shift-left +8) n.dec))
+ (|> +1 (bit;shift-left +8) n/dec))
(def: byte-to-nat
(-> (primitive java.lang.Byte) Nat)
@@ -32,45 +32,45 @@
(def: #export (read-8 idx blob)
(-> Nat Blob (E;Error Nat))
- (if (n.< (host;array-length blob) idx)
+ (if (n/< (host;array-length blob) idx)
(|> (host;array-read idx blob) byte-to-nat #E;Success)
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (read-16 idx blob)
(-> Nat Blob (E;Error Nat))
- (if (n.< (host;array-length blob) (n.+ +1 idx))
+ (if (n/< (host;array-length blob) (n/+ +1 idx))
(#E;Success ($_ bit;or
(bit;shift-left +8 (byte-to-nat (host;array-read idx blob)))
- (byte-to-nat (host;array-read (n.+ +1 idx) blob))))
+ (byte-to-nat (host;array-read (n/+ +1 idx) blob))))
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (read-32 idx blob)
(-> Nat Blob (E;Error Nat))
- (if (n.< (host;array-length blob) (n.+ +3 idx))
+ (if (n/< (host;array-length blob) (n/+ +3 idx))
(#E;Success ($_ bit;or
(bit;shift-left +24 (byte-to-nat (host;array-read idx blob)))
- (bit;shift-left +16 (byte-to-nat (host;array-read (n.+ +1 idx) blob)))
- (bit;shift-left +8 (byte-to-nat (host;array-read (n.+ +2 idx) blob)))
- (byte-to-nat (host;array-read (n.+ +3 idx) blob))))
+ (bit;shift-left +16 (byte-to-nat (host;array-read (n/+ +1 idx) blob)))
+ (bit;shift-left +8 (byte-to-nat (host;array-read (n/+ +2 idx) blob)))
+ (byte-to-nat (host;array-read (n/+ +3 idx) blob))))
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (read-64 idx blob)
(-> Nat Blob (E;Error Nat))
- (if (n.< (host;array-length blob) (n.+ +7 idx))
+ (if (n/< (host;array-length blob) (n/+ +7 idx))
(#E;Success ($_ bit;or
(bit;shift-left +56 (byte-to-nat (host;array-read idx blob)))
- (bit;shift-left +48 (byte-to-nat (host;array-read (n.+ +1 idx) blob)))
- (bit;shift-left +40 (byte-to-nat (host;array-read (n.+ +2 idx) blob)))
- (bit;shift-left +32 (byte-to-nat (host;array-read (n.+ +3 idx) blob)))
- (bit;shift-left +24 (byte-to-nat (host;array-read (n.+ +4 idx) blob)))
- (bit;shift-left +16 (byte-to-nat (host;array-read (n.+ +5 idx) blob)))
- (bit;shift-left +8 (byte-to-nat (host;array-read (n.+ +6 idx) blob)))
- (byte-to-nat (host;array-read (n.+ +7 idx) blob))))
+ (bit;shift-left +48 (byte-to-nat (host;array-read (n/+ +1 idx) blob)))
+ (bit;shift-left +40 (byte-to-nat (host;array-read (n/+ +2 idx) blob)))
+ (bit;shift-left +32 (byte-to-nat (host;array-read (n/+ +3 idx) blob)))
+ (bit;shift-left +24 (byte-to-nat (host;array-read (n/+ +4 idx) blob)))
+ (bit;shift-left +16 (byte-to-nat (host;array-read (n/+ +5 idx) blob)))
+ (bit;shift-left +8 (byte-to-nat (host;array-read (n/+ +6 idx) blob)))
+ (byte-to-nat (host;array-read (n/+ +7 idx) blob))))
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (write-8 idx value blob)
(-> Nat Nat Blob (E;Error Unit))
- (if (n.< (host;array-length blob) idx)
+ (if (n/< (host;array-length blob) idx)
(exec (|> blob
(host;array-write idx (host;l2b (:! Int value))))
(#E;Success []))
@@ -78,36 +78,36 @@
(def: #export (write-16 idx value blob)
(-> Nat Nat Blob (E;Error Unit))
- (if (n.< (host;array-length blob) (n.+ +1 idx))
+ (if (n/< (host;array-length blob) (n/+ +1 idx))
(exec (|> blob
(host;array-write idx (host;l2b (:! Int (bit;shift-right +8 value))))
- (host;array-write (n.+ +1 idx) (host;l2b (:! Int value))))
+ (host;array-write (n/+ +1 idx) (host;l2b (:! Int value))))
(#E;Success []))
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (write-32 idx value blob)
(-> Nat Nat Blob (E;Error Unit))
- (if (n.< (host;array-length blob) (n.+ +3 idx))
+ (if (n/< (host;array-length blob) (n/+ +3 idx))
(exec (|> blob
(host;array-write idx (host;l2b (:! Int (bit;shift-right +24 value))))
- (host;array-write (n.+ +1 idx) (host;l2b (:! Int (bit;shift-right +16 value))))
- (host;array-write (n.+ +2 idx) (host;l2b (:! Int (bit;shift-right +8 value))))
- (host;array-write (n.+ +3 idx) (host;l2b (:! Int value))))
+ (host;array-write (n/+ +1 idx) (host;l2b (:! Int (bit;shift-right +16 value))))
+ (host;array-write (n/+ +2 idx) (host;l2b (:! Int (bit;shift-right +8 value))))
+ (host;array-write (n/+ +3 idx) (host;l2b (:! Int value))))
(#E;Success []))
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (write-64 idx value blob)
(-> Nat Nat Blob (E;Error Unit))
- (if (n.< (host;array-length blob) (n.+ +7 idx))
+ (if (n/< (host;array-length blob) (n/+ +7 idx))
(exec (|> blob
(host;array-write idx (host;l2b (:! Int (bit;shift-right +56 value))))
- (host;array-write (n.+ +1 idx) (host;l2b (:! Int (bit;shift-right +48 value))))
- (host;array-write (n.+ +2 idx) (host;l2b (:! Int (bit;shift-right +40 value))))
- (host;array-write (n.+ +3 idx) (host;l2b (:! Int (bit;shift-right +32 value))))
- (host;array-write (n.+ +4 idx) (host;l2b (:! Int (bit;shift-right +24 value))))
- (host;array-write (n.+ +5 idx) (host;l2b (:! Int (bit;shift-right +16 value))))
- (host;array-write (n.+ +6 idx) (host;l2b (:! Int (bit;shift-right +8 value))))
- (host;array-write (n.+ +7 idx) (host;l2b (:! Int value))))
+ (host;array-write (n/+ +1 idx) (host;l2b (:! Int (bit;shift-right +48 value))))
+ (host;array-write (n/+ +2 idx) (host;l2b (:! Int (bit;shift-right +40 value))))
+ (host;array-write (n/+ +3 idx) (host;l2b (:! Int (bit;shift-right +32 value))))
+ (host;array-write (n/+ +4 idx) (host;l2b (:! Int (bit;shift-right +24 value))))
+ (host;array-write (n/+ +5 idx) (host;l2b (:! Int (bit;shift-right +16 value))))
+ (host;array-write (n/+ +6 idx) (host;l2b (:! Int (bit;shift-right +8 value))))
+ (host;array-write (n/+ +7 idx) (host;l2b (:! Int value))))
(#E;Success []))
(ex;throw Index-Out-Of-Bounds (%n idx))))
@@ -119,19 +119,19 @@
(-> Nat Nat Blob (E;Error Blob))
(with-expansions [<description> (as-is (format "from = " (%n from) " | " "to = " (%n to)))]
(let [size (host;array-length blob)]
- (cond (not (n.<= to from))
+ (cond (not (n/<= to from))
(ex;throw Inverted-Range <description>)
- (not (and (n.< size from)
- (n.< size to)))
+ (not (and (n/< size from)
+ (n/< size to)))
(ex;throw Index-Out-Of-Bounds <description>)
## else
- (#E;Success (Arrays.copyOfRange [blob (:! Int from) (:! Int (n.inc to))]))))))
+ (#E;Success (Arrays.copyOfRange [blob (:! Int from) (:! Int (n/inc to))]))))))
(def: #export (slice' from blob)
(-> Nat Blob (E;Error Blob))
- (slice from (n.dec (host;array-length blob)) blob))
+ (slice from (n/dec (host;array-length blob)) blob))
(struct: #export _ (eq;Eq Blob)
(def: (= reference sample)
diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux
index 1c968b888..1e95e7354 100644
--- a/stdlib/source/lux/world/file.lux
+++ b/stdlib/source/lux/world/file.lux
@@ -71,7 +71,7 @@
stream (FileInputStream.new [file'])
bytes-read (InputStream.read [data] stream)
_ (AutoCloseable.close [] stream)]
- (if (i.= size bytes-read)
+ (if (i/= size bytes-read)
(wrap data)
(io;io (ex;throw Could-Not-Read-All-Data file))))))