From cc16e4ba982a9a2b228c7b40d927f539c9e1a5c8 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 4 Apr 2019 18:30:46 -0400 Subject: Changed the order of the inputs to the common extensions. --- stdlib/source/lux.lux | 194 ++++++++++++++++++++++++-------------------------- 1 file changed, 95 insertions(+), 99 deletions(-) (limited to 'stdlib/source/lux.lux') diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 2c550ebd9..412169967 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -1086,10 +1086,10 @@ #Nil} [xs ys])) -(def:'' (text@= x y) +(def:'' (text@= reference sample) #Nil (#Function Text (#Function Text Bit)) - ("lux text =" x y)) + ("lux text =" reference sample)) (def:'' (get-rep key env) #Nil @@ -1140,14 +1140,14 @@ (#.Cons export-meta #.Nil)) (#Function Nat (#Function Nat Nat)) - ("lux i64 +" param subject)) + ("lux i64 +" subject param)) (def:'' (n/- param subject) (#.Cons (doc-meta "Nat(ural) substraction.") (#.Cons export-meta #.Nil)) (#Function Nat (#Function Nat Nat)) - ("lux i64 -" subject param)) + ("lux i64 -" param subject)) (def:'' (n/* param subject) (#.Cons (doc-meta "Nat(ural) multiplication.") @@ -1156,8 +1156,8 @@ (#Function Nat (#Function Nat Nat)) ("lux coerce" Nat ("lux int *" - ("lux coerce" Int subject) - ("lux coerce" Int param)))) + ("lux coerce" Int param) + ("lux coerce" Int subject)))) (def:'' (update-parameters code) #Nil @@ -2206,11 +2206,11 @@ (-> (-> a Bit) ($' List a) Bit)) (list@fold (function' [_2 _1] (if _1 (p _2) #0)) #1 xs)) -(def:''' #export (n/= test subject) +(def:''' #export (n/= reference sample) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) equivalence.")]) (-> Nat Nat Bit) - ("lux i64 =" test subject)) + ("lux i64 =" reference sample)) (def:''' (high-bits value) (list) @@ -2220,48 +2220,48 @@ (def:''' low-mask (list) I64 - ("lux i64 -" ("lux i64 left-shift" 32 1) 1)) + (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))) (def:''' (low-bits value) (list) (-> ($' I64 Any) I64) ("lux i64 and" low-mask value)) -(def:''' #export (n/< test subject) +(def:''' #export (n/< reference sample) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) less-than.")]) (-> Nat Nat Bit) - (let' [testH (high-bits test) - subjectH (high-bits subject)] - (if ("lux int <" subjectH testH) + (let' [referenceH (high-bits reference) + sampleH (high-bits sample)] + (if ("lux int <" referenceH sampleH) #1 - (if ("lux i64 =" subjectH testH) + (if ("lux i64 =" referenceH sampleH) ("lux int <" - (low-bits subject) - (low-bits test)) + (low-bits reference) + (low-bits sample)) #0)))) -(def:''' #export (n/<= test subject) +(def:''' #export (n/<= reference sample) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) less-than-equal.")]) (-> Nat Nat Bit) - (if (n/< test subject) + (if (n/< reference sample) #1 - ("lux i64 =" test subject))) + ("lux i64 =" reference sample))) -(def:''' #export (n/> test subject) +(def:''' #export (n/> reference sample) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) greater-than.")]) (-> Nat Nat Bit) - (n/< subject test)) + (n/< sample reference)) -(def:''' #export (n/>= test subject) +(def:''' #export (n/>= reference sample) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) greater-than-equal.")]) (-> Nat Nat Bit) - (if (n/< subject test) + (if (n/< sample reference) #1 - ("lux i64 =" test subject))) + ("lux i64 =" reference sample))) (macro:' #export (template tokens) (list [(tag$ ["lux" "doc"]) @@ -2292,78 +2292,78 @@ (fail "Wrong syntax for template")} tokens)) -(def:''' #export (r/= test subject) +(def:''' #export (r/= reference sample) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) equivalence.")]) (-> Rev Rev Bit) - ("lux i64 =" test subject)) + ("lux i64 =" reference sample)) -(def:''' #export (r/< test subject) +(def:''' #export (r/< reference sample) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) less-than.")]) (-> Rev Rev Bit) - (n/< ("lux coerce" Nat test) - ("lux coerce" Nat subject))) + (n/< ("lux coerce" Nat reference) + ("lux coerce" Nat sample))) -(def:''' #export (r/<= test subject) +(def:''' #export (r/<= reference sample) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) less-than-equal.")]) (-> Rev Rev Bit) - (if (n/< ("lux coerce" Nat test) - ("lux coerce" Nat subject)) + (if (n/< ("lux coerce" Nat reference) + ("lux coerce" Nat sample)) #1 - ("lux i64 =" test subject))) + ("lux i64 =" reference sample))) -(def:''' #export (r/> test subject) +(def:''' #export (r/> reference sample) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) greater-than.")]) (-> Rev Rev Bit) - (r/< subject test)) + (r/< sample reference)) -(def:''' #export (r/>= test subject) +(def:''' #export (r/>= reference sample) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) greater-than-equal.")]) (-> Rev Rev Bit) - (if (r/< subject test) + (if (r/< sample reference) #1 - ("lux i64 =" test subject))) + ("lux i64 =" reference sample))) (template [ - - <<-doc> <<=-doc> <>-doc> <>=-doc>] - [(def:''' #export ( test subject) + + <<-doc> <<=-doc> <>-doc> <>=-doc>] + [(def:''' #export ( reference sample) (list [(tag$ ["lux" "doc"]) (text$ )]) (-> Bit) - ( subject test)) + ( reference sample)) - (def:''' #export ( test subject) + (def:''' #export ( reference sample) (list [(tag$ ["lux" "doc"]) (text$ <<-doc>)]) (-> Bit) - ( subject test)) + ( reference sample)) - (def:''' #export ( test subject) + (def:''' #export ( reference sample) (list [(tag$ ["lux" "doc"]) (text$ <<=-doc>)]) (-> Bit) - (if ( subject test) + (if ( reference sample) #1 - ( subject test))) + ( reference sample))) - (def:''' #export ( test subject) + (def:''' #export ( reference sample) (list [(tag$ ["lux" "doc"]) (text$ <>-doc>)]) (-> Bit) - ( test subject)) + ( sample reference)) - (def:''' #export ( test subject) + (def:''' #export ( reference sample) (list [(tag$ ["lux" "doc"]) (text$ <>=-doc>)]) (-> Bit) - (if ( test subject) + (if ( sample reference) #1 - ( subject test)))] + ( reference sample)))] [ Int "lux i64 =" "lux int <" i/= i/< i/<= i/> i/>= "Int(eger) equivalence." "Int(eger) less-than." "Int(eger) less-than-equal." "Int(eger) greater-than." "Int(eger) greater-than-equal."] @@ -2376,19 +2376,18 @@ (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) division.")]) (-> Nat Nat Nat) - (if ("lux int <" ("lux coerce" Int param) +0) + (if ("lux int <" +0 ("lux coerce" Int param)) (if (n/< param subject) 0 1) - (let' [quotient ("lux i64 left-shift" - 1 - ("lux int /" - ("lux i64 logical-right-shift" 1 subject) - ("lux coerce" Int param))) + (let' [quotient (|> subject + ("lux i64 logical-right-shift" 1) + ("lux int /" ("lux coerce" Int param)) + ("lux i64 left-shift" 1)) flat ("lux int *" - ("lux coerce" Int quotient) - ("lux coerce" Int param)) - remainder ("lux i64 -" subject flat)] + ("lux coerce" Int param) + ("lux coerce" Int quotient)) + remainder ("lux i64 -" flat subject)] (if (n/< param remainder) quotient ("lux i64 +" 1 quotient))))) @@ -2399,25 +2398,25 @@ (-> Nat Nat (#Product Nat Nat)) (let' [div (n// param subject) flat ("lux int *" - ("lux coerce" Int div) - ("lux coerce" Int param))] - [div ("lux i64 -" subject flat)])) + ("lux coerce" Int param) + ("lux coerce" Int div))] + [div ("lux i64 -" flat subject)])) (def:''' #export (n/% param subject) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) remainder.")]) (-> Nat Nat Nat) (let' [flat ("lux int *" - ("lux coerce" Int (n// param subject)) - ("lux coerce" Int param))] - ("lux i64 -" subject flat))) + ("lux coerce" Int param) + ("lux coerce" Int (n// param subject)))] + ("lux i64 -" flat subject))) (template [ ] [(def:''' #export ( param subject) (list [(tag$ ["lux" "doc"]) (text$ )]) (-> ) - ( subject param))] + ( param subject))] [ Int i/+ "lux i64 +" "Int(eger) addition."] [ Int i/- "lux i64 -" "Int(eger) substraction."] @@ -2431,7 +2430,7 @@ (list [(tag$ ["lux" "doc"]) (text$ )]) (-> ) - ( subject param))] + ( param subject))] [ Int i/* "lux int *" "Int(eger) multiplication."] [ Int i// "lux int /" "Int(eger) division."] @@ -2456,8 +2455,8 @@ ("lux int *" paramL) ("lux i64 logical-right-shift" 32)) middle ("lux i64 +" - ("lux int *" subjectH paramL) - ("lux int *" subjectL paramH)) + ("lux int *" paramL subjectH) + ("lux int *" paramH subjectL)) top ("lux int *" subjectH paramH)] (|> bottom ("lux i64 +" middle) @@ -2488,31 +2487,28 @@ (if ("lux i64 =" +0 trailing-zeroes) [1 ("lux i64 logical-right-shift" 1 remaining)] [trailing-zeroes remaining])) - shift ("lux i64 -" 64 trailing-zeroes) + shift ("lux i64 -" trailing-zeroes 64) numerator ("lux i64 left-shift" shift 1)] - ("lux coerce" Rev - ("lux int *" - ("lux coerce" Int subject) - ("lux int /" - ("lux coerce" Int numerator) - ("lux coerce" Int denominator))))))) + (|> ("lux coerce" Int numerator) + ("lux int /" ("lux coerce" Int denominator)) + ("lux int *" ("lux coerce" Int subject)) + ("lux coerce" Rev))))) (def:''' #export (r/% param subject) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) remainder.")]) (-> Rev Rev Rev) - ("lux coerce" Rev - (n/% ("lux coerce" Nat param) - ("lux coerce" Nat subject)))) + (|> ("lux coerce" Nat subject) + (n/% ("lux coerce" Nat param)) + ("lux coerce" Rev))) (def:''' #export (r/scale param subject) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) scale.")]) (-> Nat Rev Rev) - ("lux coerce" Rev - ("lux int *" - ("lux coerce" Int subject) - ("lux coerce" Int param)))) + (|> ("lux coerce" Int subject) + ("lux int *" ("lux coerce" Int param)) + ("lux coerce" Rev))) (def:''' #export (r/reciprocal numerator) (list [(tag$ ["lux" "doc"]) @@ -3587,11 +3583,11 @@ (def: (index-of part text) (-> Text Text (Maybe Nat)) - ("lux text index" text part 0)) + ("lux text index" 0 part text)) (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" (n/+ part-size since) part text) #None (#Some since) @@ -3600,7 +3596,7 @@ (def: (last-index-of part text) (-> Text Text (Maybe Nat)) - (case ("lux text index" text part 0) + (case ("lux text index" 0 part text) (#Some since) (last-index-of' part ("lux text size" part) since text) @@ -3611,14 +3607,14 @@ (-> Nat Text (Maybe Text)) (let [size ("lux text size" text)] (if (n/<= size from) - (#.Some ("lux text clip" text from size)) + (#.Some ("lux text clip" from size text)) #.None))) (def: (clip/2 from to text) (-> Nat Nat Text (Maybe Text)) (if (and (n/<= to from) (n/<= ("lux text size" text) to)) - (#.Some ("lux text clip" text from to)) + (#.Some ("lux text clip" from to text)) #.None)) (def: #export (error! message) @@ -3657,9 +3653,9 @@ (list input) (#Some idx) - (list& ("lux text clip" input 0 idx) + (list& ("lux text clip" 0 idx input) (text@split-all-with splitter - ("lux text clip" input (n/+ 1 idx) ("lux text size" input)))))) + ("lux text clip" (n/+ 1 idx) ("lux text size" input) input))))) (def: (nth idx xs) (All [a] @@ -4142,8 +4138,8 @@ (def: (split! at x) (-> Nat Text [Text Text]) - [("lux text clip" x 0 at) - ("lux text clip" x at ("lux text size" x))]) + [("lux text clip" 0 at x) + ("lux text clip" at ("lux text size" x) x)]) (def: (split-with token sample) (-> Text Text (Maybe [Text Text])) @@ -4175,7 +4171,7 @@ (def: (count-relatives relatives input) (-> Nat Text Nat) - (case ("lux text index" input ..module-separator relatives) + (case ("lux text index" relatives ..module-separator input) #None relatives @@ -4220,7 +4216,7 @@ list@reverse (interpose ..module-separator) (text@join-with "")) - clean ("lux text clip" module relatives ("lux text size" module)) + clean ("lux text clip" relatives ("lux text size" module) module) output (case ("lux text size" clean) 0 prefix _ ($_ text@compose prefix ..module-separator clean))] @@ -5170,7 +5166,7 @@ (template [ ] [(def: #export ( n) (-> ) - ( [n]))] + ( n))] [frac-to-int Frac Int "lux frac int"] [int-to-frac Int Frac "lux int frac"] @@ -5221,10 +5217,10 @@ ($_ text@compose ..double-quote original ..double-quote)) (template [ ] - [(def: #export ( value) + [(def: #export {#.doc } (All [s] (-> (I64 s) (I64 s))) - ( value 1))] + (|>> ( 1)))] [inc "lux i64 +" "Increment function."] [dec "lux i64 -" "Decrement function."] -- cgit v1.2.3 From 2914f38f7c3795a63f555409361bc1b317e871a9 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 4 Apr 2019 20:40:50 -0400 Subject: Forgot "lux text char". --- stdlib/source/lux.lux | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stdlib/source/lux.lux') diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 412169967..45b190c82 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -5999,7 +5999,7 @@ (case tokens (^multi (^ (list [_ (#Text input)])) (n/= 1 ("lux text size" input))) - (|> ("lux text char" input 0) + (|> input ("lux text char" 0) nat$ list [compiler] #Right) -- cgit v1.2.3