aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2018-05-06 02:01:02 -0400
committerEduardo Julian2018-05-06 02:01:02 -0400
commitf5a6fe62a612c0727063fa9e530d53ddda5fcd82 (patch)
tree4c129edee0d68e00e72dd792311ae0c37d71d1dd
parent3f5cb79407289996b107c65ccd14451e4fbd9679 (diff)
- Removed "lux text upper" and "lux text lower" procedures.
-rw-r--r--luxc/src/lux/analyser/proc/common.clj17
-rw-r--r--luxc/src/lux/compiler/js/proc/common.clj14
-rw-r--r--luxc/src/lux/compiler/jvm/proc/common.clj16
-rw-r--r--new-luxc/source/luxc/lang/extension/analysis/common.lux2
-rw-r--r--new-luxc/source/luxc/lang/translation/common-lisp.lux2
-rw-r--r--new-luxc/source/luxc/lang/translation/common-lisp/eval.jvm.lux2
-rw-r--r--new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux2
-rw-r--r--new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux5
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux4
-rw-r--r--new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux8
-rw-r--r--new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux2
-rw-r--r--new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux2
-rw-r--r--new-luxc/source/luxc/lang/translation/r/procedure/common.jvm.lux2
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux5
-rw-r--r--new-luxc/source/luxc/lang/translation/scheme/procedure/common.jvm.lux2
-rw-r--r--new-luxc/test/test/luxc/lang/translation/common.lux13
-rw-r--r--stdlib/source/lux/data/number.lux189
-rw-r--r--stdlib/source/lux/data/text.lux9
-rw-r--r--stdlib/test/test/lux/data/text.lux8
-rw-r--r--stdlib/test/tests.lux10
20 files changed, 156 insertions, 158 deletions
diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj
index 94eadb72c..80271f9e7 100644
--- a/luxc/src/lux/analyser/proc/common.clj
+++ b/luxc/src/lux/analyser/proc/common.clj
@@ -110,21 +110,6 @@
^:private analyse-text-hash "hash"
)
-(do-template [<name> <proc>]
- (defn <name> [analyse exo-type ?values]
- (|do [:let [(&/$Cons text (&/$Nil)) ?values]
- =text (&&/analyse-1 analyse &type/Text text)
- _ (&type/check exo-type &type/Text)
- _cursor &/cursor]
- (return (&/|list (&&/|meta exo-type _cursor
- (&&/$proc (&/T ["text" <proc>])
- (&/|list =text)
- (&/|list)))))))
-
- ^:private analyse-text-upper "upper"
- ^:private analyse-text-lower "lower"
- )
-
(defn ^:private analyse-text-char [analyse exo-type ?values]
(|do [:let [(&/$Cons text (&/$Cons idx (&/$Nil))) ?values]
=text (&&/analyse-1 analyse &type/Text text)
@@ -511,8 +496,6 @@
"lux text hash" (analyse-text-hash analyse exo-type ?values)
"lux text replace-all" (analyse-text-replace-all analyse exo-type ?values)
"lux text char" (analyse-text-char analyse exo-type ?values)
- "lux text upper" (analyse-text-upper analyse exo-type ?values)
- "lux text lower" (analyse-text-lower analyse exo-type ?values)
"lux text contains?" (analyse-text-contains? analyse exo-type ?values)
"lux bit count" (analyse-bit-count analyse exo-type ?values)
diff --git a/luxc/src/lux/compiler/js/proc/common.clj b/luxc/src/lux/compiler/js/proc/common.clj
index 96261e8d4..7044f8447 100644
--- a/luxc/src/lux/compiler/js/proc/common.clj
+++ b/luxc/src/lux/compiler/js/proc/common.clj
@@ -288,17 +288,6 @@
=idx (compile ?idx)]
(return (str "LuxRT$textChar(" (str =text "," =idx) ")"))))
-(do-template [<name> <method>]
- (defn <name> [compile ?values special-args]
- (|do [:let [(&/$Cons ?text (&/$Nil)) ?values]
- =text (compile ?text)]
- (return (str "(" =text ")." <method> "()"))))
-
- ^:private compile-text-trim "trim"
- ^:private compile-text-upper "toUpperCase"
- ^:private compile-text-lower "toLowerCase"
- )
-
(defn ^:private compile-char-to-text [compile ?values special-args]
(|do [:let [(&/$Cons ?x (&/$Nil)) ?values]
=x (compile ?x)]
@@ -446,10 +435,7 @@
"size" (compile-text-size compile ?values special-args)
"hash" (compile-text-hash compile ?values special-args)
"replace-all" (compile-text-replace-all compile ?values special-args)
- "trim" (compile-text-trim compile ?values special-args)
"char" (compile-text-char compile ?values special-args)
- "upper" (compile-text-upper compile ?values special-args)
- "lower" (compile-text-lower compile ?values special-args)
"contains?" (compile-text-contains? compile ?values special-args)
)
diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/luxc/src/lux/compiler/jvm/proc/common.clj
index e9e565f6d..138a56a26 100644
--- a/luxc/src/lux/compiler/jvm/proc/common.clj
+++ b/luxc/src/lux/compiler/jvm/proc/common.clj
@@ -596,20 +596,6 @@
&&/wrap-boolean)]]
(return nil)))
-(do-template [<name> <method>]
- (defn <name> [compile ?values special-args]
- (|do [:let [(&/$Cons ?text (&/$Nil)) ?values]
- ^MethodVisitor *writer* &/get-writer
- _ (compile ?text)
- :let [_ (doto *writer*
- (.visitTypeInsn Opcodes/CHECKCAST "java/lang/String")
- (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" <method> "()Ljava/lang/String;"))]]
- (return nil)))
-
- ^:private compile-text-upper "toUpperCase"
- ^:private compile-text-lower "toLowerCase"
- )
-
(defn ^:private compile-text-char [compile ?values special-args]
(|do [:let [(&/$Cons ?text (&/$Cons ?idx (&/$Nil))) ?values]
^MethodVisitor *writer* &/get-writer
@@ -841,8 +827,6 @@
"hash" (compile-text-hash compile ?values special-args)
"replace-all" (compile-text-replace-all compile ?values special-args)
"char" (compile-text-char compile ?values special-args)
- "upper" (compile-text-upper compile ?values special-args)
- "lower" (compile-text-lower compile ?values special-args)
"contains?" (compile-text-contains? compile ?values special-args)
)
diff --git a/new-luxc/source/luxc/lang/extension/analysis/common.lux b/new-luxc/source/luxc/lang/extension/analysis/common.lux
index aa6b6a547..220613dbf 100644
--- a/new-luxc/source/luxc/lang/extension/analysis/common.lux
+++ b/new-luxc/source/luxc/lang/extension/analysis/common.lux
@@ -294,8 +294,6 @@
(install "replace-all" (trinary Text Text Text Text))
(install "char" (binary Text Nat (type (Maybe Nat))))
(install "clip" (trinary Text Nat Nat (type (Maybe Text))))
- (install "upper" (unary Text Text))
- (install "lower" (unary Text Text))
)))
(def: (array//get proc)
diff --git a/new-luxc/source/luxc/lang/translation/common-lisp.lux b/new-luxc/source/luxc/lang/translation/common-lisp.lux
index 4e18c48cf..704dfe91e 100644
--- a/new-luxc/source/luxc/lang/translation/common-lisp.lux
+++ b/new-luxc/source/luxc/lang/translation/common-lisp.lux
@@ -178,7 +178,7 @@
[interpret #interpreter LispObject]
)
-(def: #export variant-tag "lux-variant")
+(def: #export variant-tag "LUX-VARIANT")
(def: #export unit Text "")
diff --git a/new-luxc/source/luxc/lang/translation/common-lisp/eval.jvm.lux b/new-luxc/source/luxc/lang/translation/common-lisp/eval.jvm.lux
index 262f3f284..ee2aac932 100644
--- a/new-luxc/source/luxc/lang/translation/common-lisp/eval.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/common-lisp/eval.jvm.lux
@@ -101,7 +101,7 @@
(-> (-> Object (Error Top)) Cons (Error Top))
(let [variant-tag (Cons::car host-object)]
(if (and (host.instance? org/armedbear/lisp/Symbol variant-tag)
- (text/= //.variant-tag (text.lower-case (Symbol::getName [] (:! Symbol variant-tag)))))
+ (text/= //.variant-tag (Symbol::getName [] (:! Symbol variant-tag))))
(do e.Monad<Error>
[#let [host-object (:! Cons (Cons::cdr host-object))]
tag (lux-object (Cons::car host-object))
diff --git a/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux
index 895ed8d72..fe9fe43be 100644
--- a/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux
@@ -345,8 +345,6 @@
## (install "replace-all" (trinary text//replace-all))
(install "char" (binary text//char))
(install "clip" (trinary text//clip))
- (install "upper" (unary _.string-upcase/1))
- (install "lower" (unary _.string-downcase/1))
)))
## [[Math]]
diff --git a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux
index 8e40799f2..15c48a138 100644
--- a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux
@@ -325,9 +325,6 @@
(format inputJS <op>))]
[text//size ".length"]
- [text//trim ".trim()"]
- [text//upper ".toUpperCase()"]
- [text//lower ".toLowerCase()"]
)
(do-template [<name> <method>]
@@ -567,8 +564,6 @@
(install "replace-all" (trinary text//replace-all))
(install "char" (binary text//char))
(install "clip" (trinary text//clip))
- (install "upper" (unary text//upper))
- (install "lower" (unary text//lower))
)))
(def: array-procs
diff --git a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux
index 9764045e7..8289fdf5a 100644
--- a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux
@@ -383,8 +383,6 @@
[text//size "java.lang.String" "length" lux-intI $t.int]
[text//hash "java.lang.Object" "hashCode" lux-intI $t.int]
- [text//upper "java.lang.String" "toUpperCase" id $String]
- [text//lower "java.lang.String" "toLowerCase" id $String]
)
(do-template [<name> <pre-subject> <pre-param> <op> <post>]
@@ -710,8 +708,6 @@
(install "replace-all" (trinary text//replace-all))
(install "char" (binary text//char))
(install "clip" (trinary text//clip))
- (install "upper" (unary text//upper))
- (install "lower" (unary text//lower))
)))
(def: array-procs
diff --git a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux
index 91906d899..2bef7cbcf 100644
--- a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux
@@ -331,14 +331,8 @@
(|>> (list) (lua.apply <op>)))]
[text//size "string.len"]
- [text//upper "string.upper"]
- [text//lower "string.lower"]
)
-(def: (text//trim inputO)
- Unary
- (lua.apply "string.match" (list inputO "^%s*(.-)%s*$")))
-
(def: (text//concat [subjectO paramO])
Binary
(format "(" subjectO " .. " paramO ")"))
@@ -557,8 +551,6 @@
(install "replace-all" (trinary text//replace-all))
(install "char" (binary text//char))
(install "clip" (trinary text//clip))
- (install "upper" (unary text//upper))
- (install "lower" (unary text//lower))
)))
(def: array-procs
diff --git a/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux
index bcbea37cf..33c7d645e 100644
--- a/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux
@@ -366,8 +366,6 @@
## (install "replace-all" (trinary text//replace-all))
## (install "char" (binary text//char))
## (install "clip" (trinary text//clip))
-## (install "upper" (unary (send0 "upper")))
-## (install "lower" (unary (send0 "lower")))
## )))
## ## [[Math]]
diff --git a/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux
index 24e4197d1..c9ebd6fd7 100644
--- a/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux
@@ -457,8 +457,6 @@
(install "replace-all" (trinary text//replace-all))
(install "char" (binary text//char))
(install "clip" (trinary text//clip))
- (install "upper" (unary (send0 "upper")))
- (install "lower" (unary (send0 "lower")))
)))
## [[Math]]
diff --git a/new-luxc/source/luxc/lang/translation/r/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/r/procedure/common.jvm.lux
index f190f88ed..bd11bca21 100644
--- a/new-luxc/source/luxc/lang/translation/r/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/r/procedure/common.jvm.lux
@@ -428,8 +428,6 @@
(install "replace-all" (trinary text//replace-all))
(install "char" (binary text//char))
(install "clip" (trinary text//clip))
- (install "upper" (unary (apply1 (r.global "toupper"))))
- (install "lower" (unary (apply1 (r.global "tolower"))))
)))
## [[Math]]
diff --git a/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux
index 8e58c06d4..ccd2699ce 100644
--- a/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux
@@ -452,9 +452,6 @@
(ruby.send <op> (list)))]
[text//size "length"]
- [text//upper "upcase"]
- [text//lower "downcase"]
- [text//trim "strip"]
[text//hash "hash"]
)
@@ -501,8 +498,6 @@
(install "replace-all" (trinary text//replace-all))
(install "char" (binary text//char))
(install "clip" (trinary text//clip))
- (install "upper" (unary text//upper))
- (install "lower" (unary text//lower))
)))
## [[Math]]
diff --git a/new-luxc/source/luxc/lang/translation/scheme/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/scheme/procedure/common.jvm.lux
index 5d8e2ac66..7387b6530 100644
--- a/new-luxc/source/luxc/lang/translation/scheme/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/scheme/procedure/common.jvm.lux
@@ -414,8 +414,6 @@
## (install "replace-all" (trinary text//replace-all))
## (install "char" (binary text//char))
## (install "clip" (trinary text//clip))
- (install "upper" (unary (_.apply1 (_.global "string-upcase"))))
- (install "lower" (unary (_.apply1 (_.global "string-downcase"))))
)))
## [[Math]]
diff --git a/new-luxc/test/test/luxc/lang/translation/common.lux b/new-luxc/test/test/luxc/lang/translation/common.lux
index be552f1f0..964be4af3 100644
--- a/new-luxc/test/test/luxc/lang/translation/common.lux
+++ b/new-luxc/test/test/luxc/lang/translation/common.lux
@@ -235,19 +235,6 @@
_
false)))
- (test "Can change case of text."
- (and (|> (run (` ("lux text =" (~ sample0S) ("lux text upper" (~ sample0S)))))
- (case> (#e.Success valueV)
- (not (:! Bool valueV))
-
- _
- false))
- (|> (run (` ("lux text =" (~ sample0S) ("lux text lower" ("lux text upper" (~ sample0S))))))
- (case> (#e.Success valueV)
- (:! Bool valueV)
-
- _
- false))))
(test "Can get length of text."
(|> (run (` ("lux text size" (~ sample0S))))
(case> (#e.Success valueV)
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index 732adbb3b..c67ad0e56 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -175,12 +175,124 @@
(-> Text Nat (Maybe Text))
("lux text clip" full idx (n/inc idx)))
-(do-template [<struct> <base> <char-set> <error>]
+(def: (binary-character value)
+ (-> Nat (Maybe Text))
+ (case value
+ +0 (#.Some "0")
+ +1 (#.Some "1")
+ _ #.None))
+
+(def: (binary-value digit)
+ (-> Text (Maybe Nat))
+ (case digit
+ "0" (#.Some +0)
+ "1" (#.Some +1)
+ _ #.None))
+
+(def: (octal-character value)
+ (-> Nat (Maybe Text))
+ (case value
+ +0 (#.Some "0")
+ +1 (#.Some "1")
+ +2 (#.Some "2")
+ +3 (#.Some "3")
+ +4 (#.Some "4")
+ +5 (#.Some "5")
+ +6 (#.Some "6")
+ +7 (#.Some "7")
+ _ #.None))
+
+(def: (octal-value digit)
+ (-> Text (Maybe Nat))
+ (case digit
+ "0" (#.Some +0)
+ "1" (#.Some +1)
+ "2" (#.Some +2)
+ "3" (#.Some +3)
+ "4" (#.Some +4)
+ "5" (#.Some +5)
+ "6" (#.Some +6)
+ "7" (#.Some +7)
+ _ #.None))
+
+(def: (decimal-character value)
+ (-> Nat (Maybe Text))
+ (case value
+ +0 (#.Some "0")
+ +1 (#.Some "1")
+ +2 (#.Some "2")
+ +3 (#.Some "3")
+ +4 (#.Some "4")
+ +5 (#.Some "5")
+ +6 (#.Some "6")
+ +7 (#.Some "7")
+ +8 (#.Some "8")
+ +9 (#.Some "9")
+ _ #.None))
+
+(def: (decimal-value digit)
+ (-> Text (Maybe Nat))
+ (case digit
+ "0" (#.Some +0)
+ "1" (#.Some +1)
+ "2" (#.Some +2)
+ "3" (#.Some +3)
+ "4" (#.Some +4)
+ "5" (#.Some +5)
+ "6" (#.Some +6)
+ "7" (#.Some +7)
+ "8" (#.Some +8)
+ "9" (#.Some +9)
+ _ #.None))
+
+(def: (hexadecimal-character value)
+ (-> Nat (Maybe Text))
+ (case value
+ +0 (#.Some "0")
+ +1 (#.Some "1")
+ +2 (#.Some "2")
+ +3 (#.Some "3")
+ +4 (#.Some "4")
+ +5 (#.Some "5")
+ +6 (#.Some "6")
+ +7 (#.Some "7")
+ +8 (#.Some "8")
+ +9 (#.Some "9")
+ +10 (#.Some "A")
+ +11 (#.Some "B")
+ +12 (#.Some "C")
+ +13 (#.Some "D")
+ +14 (#.Some "E")
+ +15 (#.Some "F")
+ _ #.None))
+
+(def: (hexadecimal-value digit)
+ (-> Text (Maybe Nat))
+ (case digit
+ "0" (#.Some +0)
+ "1" (#.Some +1)
+ "2" (#.Some +2)
+ "3" (#.Some +3)
+ "4" (#.Some +4)
+ "5" (#.Some +5)
+ "6" (#.Some +6)
+ "7" (#.Some +7)
+ "8" (#.Some +8)
+ "9" (#.Some +9)
+ (^or "a" "A") (#.Some +10)
+ (^or "b" "B") (#.Some +11)
+ (^or "c" "C") (#.Some +12)
+ (^or "d" "D") (#.Some +13)
+ (^or "e" "E") (#.Some +14)
+ (^or "f" "F") (#.Some +15)
+ _ #.None))
+
+(do-template [<struct> <base> <to-character> <to-value> <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 (<to-character> (n/% <base> input)))
output' ("lux text concat" digit output)
input' (n// <base> input)]
(if (n/= +0 input')
@@ -192,31 +304,30 @@
(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)
- (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)))))
- (#e.Success output))))
+ (loop [idx +1
+ output +0]
+ (if (n/< input-size idx)
+ (let [digit (maybe.assume (get-char repr idx))]
+ (case (<to-value> digit)
+ #.None
+ (#e.Error ("lux text concat" <error> repr))
+
+ (#.Some digit-value)
+ (recur (n/inc idx)
+ (|> output (n/* <base>) (n/+ digit-value)))))
+ (#e.Success output)))
_
(#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: "]
- [_ +10 "0123456789" "Invalid syntax for Nat: "]
- [Hex@Codec<Text,Nat> +16 "0123456789ABCDEF" "Invalid hexadecimal syntax for Nat: "]
+ [Binary@Codec<Text,Nat> +2 binary-character binary-value "Invalid binary syntax for Nat: "]
+ [Octal@Codec<Text,Nat> +8 octal-character octal-value "Invalid octal syntax for Nat: "]
+ [_ +10 decimal-character decimal-value "Invalid syntax for Nat: "]
+ [Hex@Codec<Text,Nat> +16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Nat: "]
)
-(do-template [<struct> <base> <char-set> <error>]
+(do-template [<struct> <base> <to-character> <to-value> <error>]
[(struct: #export <struct> (Codec Text Int)
(def: (encode value)
(if (i/= 0 value)
@@ -226,11 +337,11 @@
"")]
(loop [input (|> value (i// <base>) (:: Number<Int> abs))
output (|> value (i/% <base>) (:: Number<Int> abs) int-to-nat
- (get-char <char-set>)
+ <to-character>
maybe.assume)]
(if (i/= 0 input)
("lux text concat" sign output)
- (let [digit (maybe.assume (get-char <char-set> (int-to-nat (i/% <base> input))))]
+ (let [digit (maybe.assume (<to-character> (int-to-nat (i/% <base> input))))]
(recur (i// <base> input)
("lux text concat" digit output))))))))
@@ -242,26 +353,25 @@
-1
_
- 1)
- input ("lux text upper" repr)]
+ 1)]
(loop [idx (if (i/= -1 sign) +1 +0)
output 0]
(if (n/< input-size idx)
- (let [digit (maybe.assume (get-char input idx))]
- (case ("lux text index" <char-set> digit +0)
+ (let [digit (maybe.assume (get-char repr idx))]
+ (case (<to-value> digit)
#.None
(#e.Error <error>)
- (#.Some index)
+ (#.Some digit-value)
(recur (n/inc idx)
- (|> output (i/* <base>) (i/+ (:! Int index))))))
+ (|> output (i/* <base>) (i/+ (:! Int digit-value))))))
(#e.Success (i/* sign output)))))
(#e.Error <error>)))))]
- [Binary@Codec<Text,Int> 2 "01" "Invalid binary syntax for Int: "]
- [Octal@Codec<Text,Int> 8 "01234567" "Invalid octal syntax for Int: "]
- [_ 10 "0123456789" "Invalid syntax for Int: "]
- [Hex@Codec<Text,Int> 16 "0123456789ABCDEF" "Invalid hexadecimal syntax for Int: "]
+ [Binary@Codec<Text,Int> 2 binary-character binary-value "Invalid binary syntax for Int: "]
+ [Octal@Codec<Text,Int> 8 octal-character octal-value "Invalid octal syntax for Int: "]
+ [_ 10 decimal-character decimal-value "Invalid syntax for Int: "]
+ [Hex@Codec<Text,Int> 16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Int: "]
)
(def: (de-prefix input)
@@ -406,12 +516,12 @@
"7" "0111"
"8" "1000"
"9" "1001"
- "A" "1010"
- "B" "1011"
- "C" "1100"
- "D" "1101"
- "E" "1110"
- "F" "1111"
+ (^or "a" "A") "1010"
+ (^or "b" "B") "1011"
+ (^or "c" "C") "1100"
+ (^or "d" "D") "1101"
+ (^or "e" "E") "1110"
+ (^or "f" "F") "1111"
_ (undefined)))
(def: (bin-segment-to-octal input)
@@ -483,8 +593,7 @@
(def: <to>
(-> Text Text)
- (|>> "lux text upper"
- (segment-digits +1)
+ (|>> (segment-digits +1)
(map <to-translator>)
re-join-chunks))]
diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux
index aeaf858cc..90f9bec02 100644
--- a/stdlib/source/lux/data/text.lux
+++ b/stdlib/source/lux/data/text.lux
@@ -27,15 +27,6 @@
_
false))
-(do-template [<name> <proc>]
- [(def: #export (<name> input)
- (-> Text Text)
- (<proc> input))]
-
- [lower-case "lux text lower"]
- [upper-case "lux text upper"]
- )
-
(def: #export (clip from to input)
(-> Nat Nat Text (Maybe Text))
("lux text clip" input from to))
diff --git a/stdlib/test/test/lux/data/text.lux b/stdlib/test/test/lux/data/text.lux
index 42685e03f..2430c9919 100644
--- a/stdlib/test/test/lux/data/text.lux
+++ b/stdlib/test/test/lux/data/text.lux
@@ -123,14 +123,6 @@
(&.replace-all sep1 sep2 sample1)))
))))
-(context: "Other text functions"
- (let [(^open "&/") &.Eq<Text>]
- ($_ seq
- (test "Can transform texts in certain ways."
- (and (&/= "abc" (&.lower-case "ABC"))
- (&/= "ABC" (&.upper-case "abc"))))
- )))
-
(context: "Structures"
(let [(^open "&/") &.Order<Text>]
($_ seq
diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux
index d4a0c0a32..694ada1c5 100644
--- a/stdlib/test/tests.lux
+++ b/stdlib/test/tests.lux
@@ -35,10 +35,13 @@
["_." maybe]
["_." product]
["_." sum]
- ["_." text]
["_." number]
(number ["_." ratio]
["_." complex])
+ ["_." text]
+ (text ["_." format]
+ ["_." lexer]
+ ["_." regex])
(format ["_." json]
["_." xml])
(coll ["_." array]
@@ -54,10 +57,7 @@
["_." queue]
(queue ["_." priority])
(tree ["_." rose]
- (rose ["_." zipper])))
- (text ["_." format]
- ["_." lexer]
- ["_." regex]))
+ (rose ["_." zipper]))))
["_." math]
(math ["_." random]
["_." modular]