diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/math/number/frac.lux | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index c602db1c5..729d9b5b7 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -22,35 +22,35 @@ ["#." rev] ["/#" //]]) -(def: #export (= reference sample) +(def: .public (= reference sample) {#.doc "Frac(tion) equivalence."} (-> Frac Frac Bit) ("lux f64 =" reference sample)) -(def: #export (< reference sample) +(def: .public (< reference sample) {#.doc "Frac(tion) less-than."} (-> Frac Frac Bit) ("lux f64 <" reference sample)) -(def: #export (<= reference sample) +(def: .public (<= reference sample) {#.doc "Frac(tion) less-than or equal."} (-> Frac Frac Bit) (or ("lux f64 <" reference sample) ("lux f64 =" reference sample))) -(def: #export (> reference sample) +(def: .public (> reference sample) {#.doc "Frac(tion) greater-than."} (-> Frac Frac Bit) ("lux f64 <" sample reference)) -(def: #export (>= reference sample) +(def: .public (>= reference sample) {#.doc "Frac(tion) greater-than or equal."} (-> Frac Frac Bit) (or ("lux f64 <" sample reference) ("lux f64 =" sample reference))) (template [<comparison> <name>] - [(def: #export <name> + [(def: .public <name> (Predicate Frac) (<comparison> +0.0))] @@ -60,7 +60,7 @@ ) (template [<name> <op> <doc>] - [(def: #export (<name> param subject) + [(def: .public (<name> param subject) {#.doc <doc>} (-> Frac Frac Frac) (<op> param subject))] @@ -72,22 +72,22 @@ [% "lux f64 %" "Frac(tion) remainder."] ) -(def: #export (/% param subject) +(def: .public (/% param subject) (-> Frac Frac [Frac Frac]) [(../ param subject) (..% param subject)]) -(def: #export opposite +(def: .public opposite (-> Frac Frac) (..* -1.0)) -(def: #export (abs x) +(def: .public (abs x) (-> Frac Frac) (if (..< +0.0 x) (..* -1.0 x) x)) -(def: #export (signum x) +(def: .public (signum x) (-> Frac Frac) (cond (..= +0.0 x) +0.0 (..< +0.0 x) -1.0 @@ -98,7 +98,7 @@ (def: max_exponent (//int.frac +1023)) (template [<name> <test> <doc>] - [(def: #export (<name> left right) + [(def: .public (<name> left right) {#.doc <doc>} (-> Frac Frac Frac) (if (<test> right left) @@ -109,11 +109,11 @@ [max ..> "Frac(tion) minimum."] ) -(def: #export nat +(def: .public nat (-> Frac Nat) (|>> "lux f64 i64" .nat)) -(def: #export int +(def: .public int (-> Frac Int) (|>> "lux f64 i64")) @@ -125,7 +125,7 @@ ("lux i64 right-shift" ..exponent_size) "lux i64 f64")) -(def: #export rev +(def: .public rev (-> Frac Rev) (|>> ..abs (..% +1.0) @@ -133,23 +133,23 @@ "lux f64 i64" ("lux i64 left-shift" ..exponent_size))) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Frac) (def: = ..=)) -(implementation: #export order +(implementation: .public order (Order Frac) (def: &equivalence ..equivalence) (def: < ..<)) -(def: #export smallest +(def: .public smallest Frac (///.pow (//int.frac (//int.- (.int ..mantissa_size) ..min_exponent)) +2.0)) -(def: #export biggest +(def: .public biggest Frac (let [f2^-52 (///.pow (//nat.frac (//nat.- ..mantissa_size 0)) +2.0) f2^+1023 (///.pow ..max_exponent +2.0)] @@ -158,7 +158,7 @@ (..* f2^+1023)))) (template [<name> <compose> <identity>] - [(implementation: #export <name> + [(implementation: .public <name> (Monoid Frac) (def: identity <identity>) @@ -171,7 +171,7 @@ ) (template [<name> <numerator> <doc>] - [(def: #export <name> + [(def: .public <name> {#.doc <doc>} Frac (../ +0.0 <numerator>))] @@ -180,23 +180,23 @@ [positive_infinity +1.0 "Positive infinity."] ) -(def: #export negative_infinity +(def: .public negative_infinity {#.doc "Negative infinity."} Frac (..* -1.0 ..positive_infinity)) -(def: #export (not_a_number? number) +(def: .public (not_a_number? number) {#.doc "Tests whether a frac is actually not-a-number."} (-> Frac Bit) (not (..= number number))) -(def: #export (number? value) +(def: .public (number? value) (-> Frac Bit) (not (or (..not_a_number? value) (..= ..positive_infinity value) (..= ..negative_infinity value)))) -(implementation: #export decimal +(implementation: .public decimal (Codec Text Frac) (def: (encode x) @@ -247,7 +247,7 @@ (def: smallest_exponent (..log/2 ..smallest)) -(def: #export (bits input) +(def: .public (bits input) (-> Frac I64) (.i64 (cond (..not_a_number? input) ..not_a_number_bits @@ -310,7 +310,7 @@ [sign 1 ..sign_offset] ) -(def: #export (of_bits input) +(def: .public (of_bits input) (-> I64 Frac) (case [(: Nat (..exponent input)) (: Nat (..mantissa input)) @@ -374,7 +374,7 @@ (#try.Success [representation +0]))) (template [<struct> <nat> <int> <error>] - [(implementation: #export <struct> + [(implementation: .public <struct> (Codec Text Frac) (def: (encode value) @@ -427,20 +427,20 @@ [hex //nat.hex //int.hex "Invalid hexadecimal syntax: "] ) -(implementation: #export hash +(implementation: .public hash (Hash Frac) (def: &equivalence ..equivalence) (def: hash ..bits)) -(def: #export (approximately? margin_of_error standard value) +(def: .public (approximately? margin_of_error standard value) (-> Frac Frac Frac Bit) (|> value (..- standard) ..abs (..< margin_of_error))) -(def: #export (mod divisor dividend) +(def: .public (mod divisor dividend) (All [m] (-> Frac Frac Frac)) (let [remainder (..% divisor dividend)] (if (or (and (..< +0.0 divisor) |