diff options
author | Eduardo Julian | 2018-07-04 00:03:28 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-07-04 00:03:28 -0400 |
commit | 971d5d8aceb5087d3b3aef9db45abe9bc9c7c844 (patch) | |
tree | 98a101f7f33451b6d657c4afa548df7e72037e47 | |
parent | 8bfbd5f1c911bdc3266d08c156bf34de1eb8c759 (diff) |
- Implemented not-a-number and both infinities in pure Lux.
Diffstat (limited to '')
15 files changed, 7 insertions, 141 deletions
diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index ac5900634..0d7b6dd1e 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -230,9 +230,6 @@ ^:private analyse-frac-smallest &type/Frac ["frac" "smallest"] ^:private analyse-frac-min &type/Frac ["frac" "min"] ^:private analyse-frac-max &type/Frac ["frac" "max"] - ^:private analyse-frac-not-a-number &type/Frac ["frac" "not-a-number"] - ^:private analyse-frac-positive-infinity &type/Frac ["frac" "positive-infinity"] - ^:private analyse-frac-negative-infinity &type/Frac ["frac" "negative-infinity"] ) (do-template [<name> <from-type> <to-type> <op>] @@ -491,9 +488,6 @@ "lux frac smallest" (analyse-frac-smallest analyse exo-type ?values) "lux frac min" (analyse-frac-min analyse exo-type ?values) "lux frac max" (analyse-frac-max analyse exo-type ?values) - "lux frac not-a-number" (analyse-frac-not-a-number analyse exo-type ?values) - "lux frac positive-infinity" (analyse-frac-positive-infinity analyse exo-type ?values) - "lux frac negative-infinity" (analyse-frac-negative-infinity analyse exo-type ?values) "lux frac int" (analyse-frac-int analyse exo-type ?values) "lux math cos" (analyse-math-cos analyse exo-type ?values) diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/luxc/src/lux/compiler/jvm/proc/common.clj index 571bbadc7..aca1921fe 100644 --- a/luxc/src/lux/compiler/jvm/proc/common.clj +++ b/luxc/src/lux/compiler/jvm/proc/common.clj @@ -248,10 +248,6 @@ ^:private compile-frac-smallest Double/MIN_VALUE ^:private compile-frac-min (* -1.0 Double/MAX_VALUE) ^:private compile-frac-max Double/MAX_VALUE - - ^:private compile-frac-not-a-number Double/NaN - ^:private compile-frac-positive-infinity Double/POSITIVE_INFINITY - ^:private compile-frac-negative-infinity Double/NEGATIVE_INFINITY ) (defn ^:private compile-frac-encode [compile ?values special-args] @@ -708,9 +704,6 @@ "smallest" (compile-frac-smallest compile ?values special-args) "max" (compile-frac-max compile ?values special-args) "min" (compile-frac-min compile ?values special-args) - "not-a-number" (compile-frac-not-a-number compile ?values special-args) - "positive-infinity" (compile-frac-positive-infinity compile ?values special-args) - "negative-infinity" (compile-frac-negative-infinity compile ?values special-args) "int" (compile-frac-int compile ?values special-args) "encode" (compile-frac-encode compile ?values special-args) "decode" (compile-frac-decode compile ?values special-args) 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 b7dd1b58a..3f878319b 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 @@ -229,16 +229,6 @@ [int//max ("lux int max")] ) -(do-template [<name> <frac>] - [(def: (<name> _) - Nullary - (_.double <frac>))] - - [frac//not-a-number number.not-a-number] - [frac//positive-infinity number.positive-infinity] - [frac//negative-infinity number.negative-infinity] - ) - (do-template [<name> <op>] [(def: (<name> [subjectO paramO]) Binary @@ -304,9 +294,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary _.floor/1))))) ## ## [[Text]] 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 1d4e0e5c4..d9e64d4a1 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 @@ -192,10 +192,7 @@ (host.import: java/lang/Double (#static MIN_VALUE Double) - (#static MAX_VALUE Double) - (#static NaN Double) - (#static POSITIVE_INFINITY Double) - (#static NEGATIVE_INFINITY Double)) + (#static MAX_VALUE Double)) (do-template [<name> <const> <encode>] [(def: (<name> _) @@ -208,9 +205,6 @@ [frac//smallest Double::MIN_VALUE runtimeT.frac] [frac//min (f/* -1.0 Double::MAX_VALUE) runtimeT.frac] [frac//max Double::MAX_VALUE runtimeT.frac] - [frac//not-a-number Double::NaN runtimeT.frac] - [frac//positive-infinity Double::POSITIVE_INFINITY runtimeT.frac] - [frac//negative-infinity Double::NEGATIVE_INFINITY runtimeT.frac] ) (do-template [<name> <op>] @@ -458,9 +452,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary frac//to-int)) (install "encode" (unary frac//encode)) (install "decode" (unary frac//decode))))) 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 db92bc413..c60c424f5 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 @@ -32,10 +32,7 @@ (host.import: java/lang/Double (#static MIN_VALUE Double) - (#static MAX_VALUE Double) - (#static NaN Double) - (#static POSITIVE_INFINITY Double) - (#static NEGATIVE_INFINITY Double)) + (#static MAX_VALUE Double)) ## [Types] (type: #export Translator @@ -267,9 +264,6 @@ [frac//smallest ($i.double Double::MIN_VALUE) #$.Double] [frac//min ($i.double (f/* -1.0 Double::MAX_VALUE)) #$.Double] [frac//max ($i.double Double::MAX_VALUE) #$.Double] - [frac//not-a-number ($i.double Double::NaN) #$.Double] - [frac//positive-infinity ($i.double Double::POSITIVE_INFINITY) #$.Double] - [frac//negative-infinity ($i.double Double::NEGATIVE_INFINITY) #$.Double] ) (do-template [<name> <type> <op>] @@ -598,9 +592,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary frac//to-int)) (install "encode" (unary frac//encode)) (install "decode" (unary frac//decode))))) 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 21baddcfc..b54829a62 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 @@ -203,16 +203,6 @@ [int//max "math.maxinteger"] ) -(do-template [<name> <expression>] - [(def: (<name> _) - Nullary - <expression>)] - - [frac//not-a-number (lua./ (lua.int 0) (lua.int 0))] - [frac//positive-infinity "math.huge"] - [frac//negative-infinity (lua.* (lua.int -1) "math.huge")] - ) - (do-template [<name> <op>] [(def: (<name> [subjectO paramO]) Binary @@ -447,9 +437,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary frac//to-int)) (install "encode" (unary frac//encode)) (install "decode" (unary frac//decode))))) 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 8ce6fe1ef..73185ff66 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 @@ -236,16 +236,6 @@ [int//max (|> (_.int 2) (_.** (_.int 63)) (_.- (_.int 1)))] ) -## (do-template [<name> <label>] -## [(def: (<name> _) -## Nullary -## (_.apply (list (_.string <label>)) (_.global "float")))] - -## [frac//not-a-number "nan"] -## [frac//positive-infinity "inf"] -## [frac//negative-infinity "-inf"] -## ) - (do-template [<name> <op>] [(def: (<name> [subjectO paramO]) Binary @@ -314,9 +304,6 @@ ## (install "smallest" (nullary frac//smallest)) ## (install "min" (nullary frac//min)) ## (install "max" (nullary frac//max)) -## (install "not-a-number" (nullary frac//not-a-number)) -## (install "positive-infinity" (nullary frac//positive-infinity)) -## (install "negative-infinity" (nullary frac//negative-infinity)) ## (install "to-int" (unary (apply1 (_.global "int")))) ## (install "encode" (unary (apply1 (_.global "repr")))) ## (install "decode" (unary runtimeT.frac//decode))))) 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 f63371bd1..e2ab5113c 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 @@ -236,16 +236,6 @@ [int//max (|> (python.int 2) (python.** (python.int 63)) (python.- (python.int 1)))] ) -(do-template [<name> <label>] - [(def: (<name> _) - Nullary - (python.apply (list (python.string <label>)) (python.global "float")))] - - [frac//not-a-number "nan"] - [frac//positive-infinity "inf"] - [frac//negative-infinity "-inf"] - ) - (do-template [<name> <op>] [(def: (<name> [subjectO paramO]) Binary @@ -334,9 +324,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary (apply1 (python.global "int")))) (install "encode" (unary (apply1 (python.global "repr")))) (install "decode" (unary runtimeT.frac//decode))))) 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 022e1ea16..9d4fdce2a 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 @@ -227,16 +227,6 @@ [int//max runtimeT.int//max] ) -(do-template [<name> <frac>] - [(def: (<name> _) - Nullary - (r.float <frac>))] - - [frac//not-a-number number.not-a-number] - [frac//positive-infinity number.positive-infinity] - [frac//negative-infinity number.negative-infinity] - ) - (do-template [<name> <op>] [(def: (<name> [subjectO paramO]) Binary @@ -316,9 +306,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary (apply1 (r.global "as.integer")))) (install "encode" (unary frac//encode)) (install "decode" (unary runtimeT.frac//decode))))) 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 7a9dfcb08..1b90e322a 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 @@ -237,16 +237,6 @@ [int//max (|> (ruby.int 2) (ruby.pow (ruby.int 63)) (ruby.- (ruby.int 1)))] ) -(do-template [<name> <expression>] - [(def: (<name> _) - Nullary - <expression>)] - - [frac//not-a-number (ruby./ (ruby.float 0.0) (ruby.float 0.0))] - [frac//positive-infinity (ruby./ (ruby.float 0.0) (ruby.float 1.0))] - [frac//negative-infinity (ruby./ (ruby.float 0.0) (ruby.float -1.0))] - ) - (do-template [<name> <op>] [(def: (<name> [subjectO paramO]) Binary @@ -339,9 +329,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary (ruby.send "floor" (list)))) (install "encode" (unary frac//encode)) (install "decode" (unary frac//decode))))) diff --git a/new-luxc/test/test/luxc/lang/translation/common.lux b/new-luxc/test/test/luxc/lang/translation/common.lux index 793abd4d5..8b6e5f4d9 100644 --- a/new-luxc/test/test/luxc/lang/translation/common.lux +++ b/new-luxc/test/test/luxc/lang/translation/common.lux @@ -160,9 +160,6 @@ ["lux frac min" (f/= frac/bottom)] ["lux frac max" (f/= frac/top)] - ["lux frac not-a-number" number.not-a-number?] - ["lux frac positive-infinity" (f/= number.positive-infinity)] - ["lux frac negative-infinity" (f/= number.negative-infinity)] ["lux frac smallest" (f/= ("lux frac smallest"))] )) (~~ (do-template [<forward> <backward> <test>] diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index df685c150..4ac938ac2 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -132,15 +132,15 @@ [ Min@Monoid<Deg> Deg (:: Interval<Deg> top) d/min] ) -(do-template [<name> <const> <doc>] +(do-template [<name> <numerator> <doc>] [(def: #export <name> {#.doc <doc>} Frac - (<const>))] + (f// 0.0 <numerator>))] - [not-a-number "lux frac not-a-number" "Not-a-number."] - [positive-infinity "lux frac positive-infinity" "Positive infinity."] - [negative-infinity "lux frac negative-infinity" "Negative infinity."] + [not-a-number 0.0 "Not a number."] + [positive-infinity 1.0 "Positive infinity."] + [negative-infinity -1.0 "Negative infinity."] ) (def: #export (not-a-number? number) diff --git a/stdlib/source/lux/lang/compiler/extension/analysis/common.lux b/stdlib/source/lux/lang/compiler/extension/analysis/common.lux index ca1c51df9..72453cac5 100644 --- a/stdlib/source/lux/lang/compiler/extension/analysis/common.lux +++ b/stdlib/source/lux/lang/compiler/extension/analysis/common.lux @@ -206,9 +206,6 @@ (///bundle.install "smallest" (nullary Frac)) (///bundle.install "min" (nullary Frac)) (///bundle.install "max" (nullary Frac)) - (///bundle.install "not-a-number" (nullary Frac)) - (///bundle.install "positive-infinity" (nullary Frac)) - (///bundle.install "negative-infinity" (nullary Frac)) (///bundle.install "to-deg" (unary Frac Deg)) (///bundle.install "to-int" (unary Frac Int)) (///bundle.install "encode" (unary Frac Text)) diff --git a/stdlib/source/lux/lang/compiler/translation/scheme/extension/common.jvm.lux b/stdlib/source/lux/lang/compiler/translation/scheme/extension/common.jvm.lux index 02bdd6109..644557bdc 100644 --- a/stdlib/source/lux/lang/compiler/translation/scheme/extension/common.jvm.lux +++ b/stdlib/source/lux/lang/compiler/translation/scheme/extension/common.jvm.lux @@ -174,16 +174,6 @@ [frac//max Double::MAX_VALUE _.float] ) -(do-template [<name> <frac>] - [(def: (<name> _) - Nullary - (_.float <frac>))] - - [frac//not-a-number number.not-a-number] - [frac//positive-infinity number.positive-infinity] - [frac//negative-infinity number.negative-infinity] - ) - (do-template [<name> <op>] [(def: (<name> [subjectO paramO]) Binary @@ -252,9 +242,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary _.exact/1)) (install "encode" (unary _.number->string/1)) (install "decode" (unary ///runtime.frac//decode))))) diff --git a/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux b/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux index 898376045..581ce90b8 100644 --- a/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux +++ b/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux @@ -133,12 +133,6 @@ (check-success+ "lux frac max" (list) Frac)) (test "Can obtain smallest frac number." (check-success+ "lux frac smallest" (list) Frac)) - (test "Can obtain not-a-number." - (check-success+ "lux frac not-a-number" (list) Frac)) - (test "Can obtain positive infinity." - (check-success+ "lux frac positive-infinity" (list) Frac)) - (test "Can obtain negative infinity." - (check-success+ "lux frac negative-infinity" (list) Frac)) (test "Can convert frac number to integer." (check-success+ "lux frac to-int" (list subjectC) Int)) (test "Can convert frac number to text." |