diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/number.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/data/text.lux | 30 |
2 files changed, 16 insertions, 18 deletions
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index cad152f2b..0c52653af 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -201,14 +201,14 @@ (if (n.< input-size idx) (let [digit (assume (_lux_proc ["text" "char"] [input idx]))] (case (_lux_proc ["text" "index"] - [input + [<char-set> (_lux_proc ["char" "to-text"] [digit])]) #;None (#;Left <error>) (#;Some index) (recur (n.inc idx) - (|> output (n.* <base>) (n.* index))))) + (|> output (n.* <base>) (n.+ index))))) (#;Right output)))))))) (macro: #export (<macro> tokens state) diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux index 9375d6876..bc350cc3a 100644 --- a/stdlib/source/lux/data/text.lux +++ b/stdlib/source/lux/data/text.lux @@ -12,40 +12,38 @@ ## [Functions] (def: #export (size x) (-> Text Nat) - (int-to-nat (_lux_proc ["jvm" "i2l"] [(_lux_proc ["jvm" "invokevirtual:java.lang.String:length:"] [x])]))) + [(_lux_proc ["text" "size"] [x])]) -(def: #export (nth idx x) +(def: #export (nth idx input) (-> Nat Text (Maybe Char)) - (if (n.< (size x) idx) - (#;Some (_lux_proc ["jvm" "invokevirtual:java.lang.String:charAt:int"] [x (_lux_proc ["jvm" "l2i"] [(nat-to-int idx)])])) - #;None)) + (_lux_proc ["text" "char"] [input idx])) (def: #export (contains? sub text) (-> Text Text Bool) (_lux_proc ["jvm" "invokevirtual:java.lang.String:contains:java.lang.CharSequence"] [text sub])) (do-template [<name> <proc>] - [(def: #export (<name> x) + [(def: #export (<name> input) (-> Text Text) - (_lux_proc ["jvm" <proc>] [x]))] - [lower-case "invokevirtual:java.lang.String:toLowerCase:"] - [upper-case "invokevirtual:java.lang.String:toUpperCase:"] - [trim "invokevirtual:java.lang.String:trim:"] + (_lux_proc ["text" <proc>] [input]))] + [lower-case "lower-case"] + [upper-case "upper-case"] + [trim "trim"] ) -(def: #export (clip from to x) +(def: #export (clip from to input) (-> Nat Nat Text (Maybe Text)) (if (and (n.< to from) - (n.<= (size x) to)) + (n.<= (size input) to)) (#;Some (_lux_proc ["jvm" "invokevirtual:java.lang.String:substring:int,int"] - [x + [input (_lux_proc ["jvm" "l2i"] [(nat-to-int from)]) (_lux_proc ["jvm" "l2i"] [(nat-to-int to)])])) #;None)) -(def: #export (clip' from x) +(def: #export (clip' from input) (-> Nat Text (Maybe Text)) - (clip from (size x) x)) + (clip from (size input) input)) (def: #export (replace pattern value template) (-> Text Text Text Text) @@ -120,7 +118,7 @@ ## [Structures] (struct: #export _ (Eq Text) (def: (= test subject) - (_lux_proc ["jvm" "invokevirtual:java.lang.Object:equals:java.lang.Object"] [subject test]))) + (_lux_proc ["text" "="] [subject test]))) (struct: #export _ (ord;Ord Text) (def: eq Eq<Text>) |