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 /stdlib | |
parent | 8bfbd5f1c911bdc3266d08c156bf34de1eb8c759 (diff) |
- Implemented not-a-number and both infinities in pure Lux.
Diffstat (limited to 'stdlib')
4 files changed, 5 insertions, 27 deletions
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." |