diff options
Diffstat (limited to 'stdlib/source/lux.lux')
-rw-r--r-- | stdlib/source/lux.lux | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index d68ef26ad..6ec614fb5 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -116,9 +116,9 @@ [dummy-cursor (+5 "Your standard, run-of-the-mill integer numbers.")]] #Nil))))]) -("lux def" Deg - (+10 ["lux" "Deg"] - (+0 "#I64" (#Cons (+0 "#Deg" #Nil) #Nil))) +("lux def" Rev + (+10 ["lux" "Rev"] + (+0 "#I64" (#Cons (+0 "#Rev" #Nil) #Nil))) [dummy-cursor (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] [dummy-cursor (+0 true)]] @@ -309,7 +309,7 @@ ## (#Bool Bool) ## (#Nat Nat) ## (#Int Int) -## (#Deg Deg) +## (#Rev Rev) ## (#Frac Frac) ## (#Text Text) ## (#Symbol Text Text) @@ -332,8 +332,8 @@ Nat (#Sum ## "lux.Int" Int - (#Sum ## "lux.Deg" - Deg + (#Sum ## "lux.Rev" + Rev (#Sum ## "lux.Frac" Frac (#Sum ## "lux.Text" @@ -355,7 +355,7 @@ [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "Bool")] (#Cons [dummy-cursor (+5 "Nat")] (#Cons [dummy-cursor (+5 "Int")] - (#Cons [dummy-cursor (+5 "Deg")] + (#Cons [dummy-cursor (+5 "Rev")] (#Cons [dummy-cursor (+5 "Frac")] (#Cons [dummy-cursor (+5 "Text")] (#Cons [dummy-cursor (+5 "Symbol")] @@ -411,9 +411,9 @@ ("lux function" _ value (_ann (#Int value)))) [dummy-cursor (#Record #Nil)]) -("lux def" deg$ - ("lux check" (#Function Deg Code) - ("lux function" _ value (_ann (#Deg value)))) +("lux def" rev$ + ("lux check" (#Function Rev Code) + ("lux function" _ value (_ann (#Rev value)))) [dummy-cursor (#Record #Nil)]) ("lux def" frac$ @@ -1900,8 +1900,8 @@ [_ [_ (#Int value)]] (return (wrap-meta (form$ (list (tag$ ["lux" "Int"]) (int$ value))))) - [_ [_ (#Deg value)]] - (return (wrap-meta (form$ (list (tag$ ["lux" "Deg"]) (deg$ value))))) + [_ [_ (#Rev value)]] + (return (wrap-meta (form$ (list (tag$ ["lux" "Rev"]) (rev$ value))))) [_ [_ (#Frac value)]] (return (wrap-meta (form$ (list (tag$ ["lux" "Frac"]) (frac$ value))))) @@ -2294,39 +2294,39 @@ _ (fail "Wrong syntax for do-template")})) -(def:''' #export (d/= test subject) +(def:''' #export (r/= test subject) (list [(tag$ ["lux" "doc"]) - (text$ "Deg(ree) equality.")]) - (-> Deg Deg Bool) + (text$ "Rev(olution) equality.")]) + (-> Rev Rev Bool) ("lux i64 =" test subject)) -(def:''' #export (d/< test subject) +(def:''' #export (r/< test subject) (list [(tag$ ["lux" "doc"]) - (text$ "Deg(ree) less-than.")]) - (-> Deg Deg Bool) + (text$ "Rev(olution) less-than.")]) + (-> Rev Rev Bool) (n/< ("lux coerce" Nat test) ("lux coerce" Nat subject))) -(def:''' #export (d/<= test subject) +(def:''' #export (r/<= test subject) (list [(tag$ ["lux" "doc"]) - (text$ "Deg(ree) less-than-equal.")]) - (-> Deg Deg Bool) + (text$ "Rev(olution) less-than-equal.")]) + (-> Rev Rev Bool) (if (n/< ("lux coerce" Nat test) ("lux coerce" Nat subject)) true ("lux i64 =" test subject))) -(def:''' #export (d/> test subject) +(def:''' #export (r/> test subject) (list [(tag$ ["lux" "doc"]) - (text$ "Deg(ree) greater-than.")]) - (-> Deg Deg Bool) - (d/< subject test)) + (text$ "Rev(olution) greater-than.")]) + (-> Rev Rev Bool) + (r/< subject test)) -(def:''' #export (d/>= test subject) +(def:''' #export (r/>= test subject) (list [(tag$ ["lux" "doc"]) - (text$ "Deg(ree) greater-than-equal.")]) - (-> Deg Deg Bool) - (if (d/< subject test) + (text$ "Rev(olution) greater-than-equal.")]) + (-> Rev Rev Bool) + (if (r/< subject test) true ("lux i64 =" test subject))) @@ -2424,8 +2424,8 @@ [ Int i/+ "lux i64 +" "Int(eger) addition."] [ Int i/- "lux i64 -" "Int(eger) substraction."] - [ Deg d/+ "lux i64 +" "Deg(ree) addition."] - [ Deg d/- "lux i64 -" "Deg(ree) substraction."] + [ Rev r/+ "lux i64 +" "Rev(olution) addition."] + [ Rev r/- "lux i64 -" "Rev(olution) substraction."] ) (do-template [<type> <name> <op> <doc>] @@ -2446,10 +2446,10 @@ [Frac f/% "lux frac %" "Frac(tion) remainder."] ) -(def:''' #export (d/* param subject) +(def:''' #export (r/* param subject) (list [(tag$ ["lux" "doc"]) - (text$ "Deg(ree) multiplication.")]) - (-> Deg Deg Deg) + (text$ "Rev(olution) multiplication.")]) + (-> Rev Rev Rev) (let' [subjectH (high-bits subject) subjectL (low-bits subject) paramH (high-bits param) @@ -2479,12 +2479,12 @@ ("lux i64 logical-right-shift" +1 remaining)) [count remaining])) -(def:''' #export (d// param subject) +(def:''' #export (r// param subject) (list [(tag$ ["lux" "doc"]) - (text$ "Deg(ree) division.")]) - (-> Deg Deg Deg) + (text$ "Rev(olution) division.")]) + (-> Rev Rev Rev) (if ("lux i64 =" 0 param) - ("lux io error" "Cannot divide Deg by zero!") + ("lux io error" "Cannot divide Rev by zero!") (let' [[trailing-zeroes remaining] (without-trailing-zeroes +0 ("lux coerce" Nat param)) [trailing-zeroes denominator] ("lux check" (#Product Nat Nat) (if ("lux i64 =" 0 trailing-zeroes) @@ -2492,35 +2492,35 @@ [trailing-zeroes remaining])) shift ("lux i64 -" trailing-zeroes +64) numerator ("lux i64 left-shift" shift +1)] - ("lux coerce" Deg + ("lux coerce" Rev ("lux int *" ("lux coerce" Int subject) ("lux int /" ("lux coerce" Int numerator) ("lux coerce" Int denominator))))))) -(def:''' #export (d/% param subject) +(def:''' #export (r/% param subject) (list [(tag$ ["lux" "doc"]) - (text$ "Deg(ree) remainder.")]) - (-> Deg Deg Deg) - ("lux coerce" Deg + (text$ "Rev(olution) remainder.")]) + (-> Rev Rev Rev) + ("lux coerce" Rev (n/% ("lux coerce" Nat subject) ("lux coerce" Nat param)))) -(def:''' #export (d/scale param subject) +(def:''' #export (r/scale param subject) (list [(tag$ ["lux" "doc"]) - (text$ "Deg(ree) scale.")]) - (-> Nat Deg Deg) - ("lux coerce" Deg + (text$ "Rev(olution) scale.")]) + (-> Nat Rev Rev) + ("lux coerce" Rev ("lux int *" ("lux coerce" Int subject) ("lux coerce" Int param)))) -(def:''' #export (d/reciprocal numerator) +(def:''' #export (r/reciprocal numerator) (list [(tag$ ["lux" "doc"]) - (text$ "Deg(ree) reciprocal of a Nat(ural).")]) - (-> Nat Deg) - ("lux coerce" Deg + (text$ "Rev(olution) reciprocal of a Nat(ural).")]) + (-> Nat Rev) + ("lux coerce" Rev (let' [[trailing-zeroes remaining] (without-trailing-zeroes +0 numerator)] (n// remaining ("lux case" trailing-zeroes @@ -2542,8 +2542,8 @@ [i/min Int i/< "Int(eger) minimum."] [i/max Int i/> "Int(eger) maximum."] - [d/min Deg d/< "Deg(ree) minimum."] - [d/max Deg d/> "Deg(ree) maximum."] + [r/min Rev r/< "Rev(olution) minimum."] + [r/max Rev r/> "Rev(olution) maximum."] [f/min Frac f/< "Frac(tion) minimum."] [f/max Frac f/> "Frac(tion) minimum."] @@ -3053,7 +3053,7 @@ [_ (#Int value)] (int/encode value) - [_ (#Deg value)] + [_ (#Rev value)] ("lux io error" "Undefined behavior.") [_ (#Frac value)] @@ -3285,8 +3285,8 @@ [_ (#Int value)] (meta-code ["lux" "Int"] (int$ value)) - [_ (#Deg value)] - (meta-code ["lux" "Deg"] (deg$ value)) + [_ (#Rev value)] + (meta-code ["lux" "Rev"] (rev$ value)) [_ (#Frac value)] (meta-code ["lux" "Frac"] (frac$ value)) @@ -5267,7 +5267,7 @@ ([#Bool] [#Nat] [#Int] - [#Deg] + [#Rev] [#Frac] [#Text] [#Symbol] @@ -5334,7 +5334,7 @@ [i64 I64] [nat Nat] [int Int] - [deg Deg] + [rev Rev] ) (def: (repeat n x) @@ -5400,7 +5400,7 @@ [#Tuple "[" "]" id] [#Record "{" "}" rejoin-all-pairs]) - [new-cursor (#Deg value)] + [new-cursor (#Rev value)] ("lux io error" "Undefined behavior.") )) @@ -5589,7 +5589,7 @@ (def: (place-tokens label tokens target) (-> Text (List Code) Code (Maybe (List Code))) (case target - (^or [_ (#Bool _)] [_ (#Nat _)] [_ (#Int _)] [_ (#Deg _)] [_ (#Frac _)] [_ (#Text _)] [_ (#Tag _)]) + (^or [_ (#Bool _)] [_ (#Nat _)] [_ (#Int _)] [_ (#Rev _)] [_ (#Frac _)] [_ (#Text _)] [_ (#Tag _)]) (#Some (list target)) [_ (#Symbol [prefix name])] @@ -5682,7 +5682,7 @@ (["Bool"] ["Nat"] ["Int"] - ["Deg"] + ["Rev"] ["Frac"] ["Text"]) @@ -5704,7 +5704,7 @@ (["Bool" Bool bool$] ["Nat" Nat nat$] ["Int" Int int$] - ["Deg" Deg deg$] + ["Rev" Rev rev$] ["Frac" Frac frac$] ["Text" Text text$]) @@ -6227,7 +6227,7 @@ ([#Bool "Bool" bool$] [#Nat "Nat" nat$] [#Int "Int" int$] - [#Deg "Deg" deg$] + [#Rev "Rev" rev$] [#Frac "Frac" frac$] [#Text "Text" text$] [#Tag "Tag" ident$] @@ -6304,7 +6304,7 @@ (<%> param subject)])] [Int i//% i// i/%] - [Deg d//% d// d/%] + [Rev r//% r// r/%] [Frac f//% f// f/%] ) @@ -6313,22 +6313,22 @@ (|>> ("lux i64 logical-right-shift" +11) int-to-frac)) -(def: deg-denominator Frac (to-significand -1)) +(def: rev-denominator Frac (to-significand -1)) -(def: #export (frac-to-deg input) - (-> Frac Deg) +(def: #export (frac-to-rev input) + (-> Frac Rev) (let [abs (if (f/< 0.0 input) (f/* -1.0 input) input)] (|> abs (f/% 1.0) - (f/* deg-denominator) + (f/* rev-denominator) frac-to-int ("lux i64 left-shift" +11)))) -(def: #export deg-to-frac - (-> Deg Frac) - (|>> to-significand (f// deg-denominator))) +(def: #export rev-to-frac + (-> Rev Frac) + (|>> to-significand (f// rev-denominator))) (macro: #export (alias: tokens) (case tokens |