diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/number.lux | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index 4dc0e4685..e9009102b 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -182,10 +182,10 @@ (loop [input value output ""] (let [digit (maybe;assume (get-char <char-set> (n.% <base> input))) - output' ("lux text append" digit output) + output' ("lux text concat" digit output) input' (n./ <base> input)] (if (n.= +0 input') - ("lux text append" "+" output') + ("lux text concat" "+" output') (recur input' output'))))) (def: (decode repr) @@ -200,7 +200,7 @@ (let [digit (maybe;assume (get-char input idx))] (case ("lux text index" <char-set> digit +0) #;None - (#E;Error ("lux text append" <error> repr)) + (#E;Error ("lux text concat" <error> repr)) (#;Some index) (recur (n.inc idx) @@ -208,8 +208,8 @@ (#E;Success output)))) _ - (#E;Error ("lux text append" <error> repr))) - (#E;Error ("lux text append" <error> repr))))))] + (#E;Error ("lux text concat" <error> repr))) + (#E;Error ("lux text concat" <error> repr))))))] [Binary@Codec<Text,Nat> +2 "01" "Invalid binary syntax for Nat: "] [Octal@Codec<Text,Nat> +8 "01234567" "Invalid octal syntax for Nat: "] @@ -230,10 +230,10 @@ (get-char <char-set>) maybe;assume)] (if (i.= 0 input) - ("lux text append" sign output) + ("lux text concat" sign output) (let [digit (maybe;assume (get-char <char-set> (int-to-nat (i.% <base> input))))] (recur (i./ <base> input) - ("lux text append" digit output)))))))) + ("lux text concat" digit output)))))))) (def: (decode repr) (let [input-size ("lux text size" repr)] @@ -280,22 +280,22 @@ (if (n.= +0 zeroes-left) output (recur (n.dec zeroes-left) - ("lux text append" "0" output)))) - padded-output ("lux text append" zero-padding raw-output)] - ("lux text append" "." padded-output))) + ("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) (case ("lux text char" repr +0) (^multi (^ (#;Some (char "."))) - [(:: <nat> decode ("lux text append" "+" (de-prefix repr))) + [(:: <nat> decode ("lux text concat" "+" (de-prefix repr))) (#;Some output)]) (#E;Success (:! Deg output)) _ - (#E;Error ("lux text append" <error> repr))) - (#E;Error ("lux text append" <error> repr))))))] + (#E;Error ("lux text concat" <error> repr))) + (#E;Error ("lux text concat" <error> repr))))))] [Binary@Codec<Text,Deg> Binary@Codec<Text,Nat> +1 "Invalid binary syntax: "] [Octal@Codec<Text,Deg> Octal@Codec<Text,Nat> +3 "Invalid octal syntax: "] @@ -313,13 +313,13 @@ (loop [dec-left decimal output ""] (if (f.= 0.0 dec-left) - ("lux text append" "." output) + ("lux text concat" "." output) (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) - ("lux text append" output digit))))))] - ("lux text append" whole-part decimal-part))) + ("lux text concat" output digit))))))] + ("lux text concat" whole-part decimal-part))) (def: (decode repr) (case ("lux text index" repr "." +0) @@ -340,7 +340,7 @@ (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 append" "." decimal-part)) + dec-deg (case (:: Hex@Codec<Text,Deg> decode ("lux text concat" "." decimal-part)) (#E;Success dec-deg) dec-deg @@ -350,10 +350,10 @@ (f.* sign adjusted-decimal)))) _ - (#E;Error ("lux text append" <error> repr)))) + (#E;Error ("lux text concat" <error> repr)))) _ - (#E;Error ("lux text append" <error> repr)))))] + (#E;Error ("lux text concat" <error> repr)))))] [Binary@Codec<Text,Frac> Binary@Codec<Text,Int> 2.0 "01" "Invalid binary syntax: "] ) @@ -457,7 +457,7 @@ "" (#;Cons x xs') - ("lux text append" x (re-join-chunks xs')))) + ("lux text concat" x (re-join-chunks xs')))) (do-template [<from> <from-translator> <to> <to-translator> <base-bits>] [(def: (<from> on-left? input) @@ -473,10 +473,10 @@ (if (n.= +0 zeroes-left) output (recur (n.dec zeroes-left) - ("lux text append" "0" output)))))) + ("lux text concat" "0" output)))))) padded-input (if on-left? - ("lux text append" zero-padding input) - ("lux text append" input zero-padding))] + ("lux text concat" zero-padding input) + ("lux text concat" input zero-padding))] (|> padded-input (segment-digits <base-bits>) (map <from-translator>) @@ -504,9 +504,9 @@ dot-idx)) 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 append" ".") - ("lux text append" (<from> true whole-part)) - ("lux text append" (if (f.= -1.0 sign) "-" "")))] + ("lux text concat" ".") + ("lux text concat" (<from> true whole-part)) + ("lux text concat" (if (f.= -1.0 sign) "-" "")))] hex-output)) (def: (decode repr) @@ -521,18 +521,18 @@ (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 append" ".") - ("lux text append" (<to> whole-part)) - ("lux text append" (if (f.= -1.0 sign) "-" "")))] + ("lux text concat" ".") + ("lux text concat" (<to> whole-part)) + ("lux text concat" (if (f.= -1.0 sign) "-" "")))] (case (:: Binary@Codec<Text,Frac> decode as-binary) (#E;Error _) - (#E;Error ("lux text append" <error> repr)) + (#E;Error ("lux text concat" <error> repr)) output output)) _ - (#E;Error ("lux text append" <error> repr))))))] + (#E;Error ("lux text concat" <error> repr))))))] [Octal@Codec<Text,Frac> "Invalid octaladecimal syntax: " binary-to-octal octal-to-binary] [Hex@Codec<Text,Frac> "Invalid hexadecimal syntax: " binary-to-hex hex-to-binary] @@ -605,7 +605,7 @@ (def: (prepend left right) (-> Text Text Text) - ("lux text append" left right)) + ("lux text concat" left right)) (def: (digits-times-5! idx output) (-> Nat Digits Digits) @@ -643,7 +643,7 @@ (recur (n.dec idx) true output) (recur (n.dec idx) false - ("lux text append" + ("lux text concat" (:: Codec<Text,Int> encode (:! Int digit)) output)))) (if all-zeroes? @@ -730,7 +730,7 @@ digits')) (recur (n.dec idx) digits)) - ("lux text append" "." (digits-to-text digits)) + ("lux text concat" "." (digits-to-text digits)) ))))) (def: (decode input) @@ -761,8 +761,8 @@ (#E;Success (:! Deg output)))) #;None - (#E;Error ("lux text append" "Wrong syntax for Deg: " input))) - (#E;Error ("lux text append" "Wrong syntax for Deg: " input)))) + (#E;Error ("lux text concat" "Wrong syntax for Deg: " input))) + (#E;Error ("lux text concat" "Wrong syntax for Deg: " input)))) )) (def: (log2 input) |