diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/math/number/complex.lux | 3 | ||||
-rw-r--r-- | stdlib/source/library/lux/math/number/frac.lux | 12 | ||||
-rw-r--r-- | stdlib/source/library/lux/math/number/i64.lux | 30 | ||||
-rw-r--r-- | stdlib/source/library/lux/math/number/int.lux | 8 | ||||
-rw-r--r-- | stdlib/source/library/lux/math/number/ratio.lux | 3 | ||||
-rw-r--r-- | stdlib/source/library/lux/math/number/rev.lux | 8 |
6 files changed, 31 insertions, 33 deletions
diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux index c374519b9..1a34bfbf5 100644 --- a/stdlib/source/library/lux/math/number/complex.lux +++ b/stdlib/source/library/lux/math/number/complex.lux @@ -33,8 +33,7 @@ "The imaginary part can be omitted if it's 0." (complex real))} (in (list (` {#..real (~ real) - #..imaginary (~ (maybe.default (' +0.0) - ?imaginary))})))) + #..imaginary (~ (maybe.else (' +0.0) ?imaginary))})))) (def: #export i (..complex +0.0 +1.0)) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index 7b6f4df5d..5576109a7 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -294,16 +294,16 @@ (//i64.and ..exponent_mask)) mantissa_bits (..int mantissa)] ($_ //i64.or - (//i64.left_shift ..sign_offset sign_bit) - (//i64.left_shift ..exponent_offset exponent_bits) + (//i64.left_shifted ..sign_offset sign_bit) + (//i64.left_shifted ..exponent_offset exponent_bits) (//i64.clear ..mantissa_size mantissa_bits))) ))) (template [<getter> <size> <offset>] [(def: <getter> (-> (I64 Any) I64) - (let [mask (|> 1 (//i64.left_shift <size>) dec (//i64.left_shift <offset>))] - (|>> (//i64.and mask) (//i64.right_shift <offset>) .i64)))] + (let [mask (|> 1 (//i64.left_shifted <size>) dec (//i64.left_shifted <offset>))] + (|>> (//i64.and mask) (//i64.right_shifted <offset>) .i64)))] [mantissa ..mantissa_size 0] [exponent ..exponent_size ..mantissa_size] @@ -417,8 +417,8 @@ #let [sign (if negative? 1 0)]] (in (..of_bits ($_ //i64.or - (//i64.left_shift ..sign_offset (.i64 sign)) - (//i64.left_shift ..mantissa_size (.i64 (//int.+ (.int ..double_bias) exponent))) + (//i64.left_shifted ..sign_offset (.i64 sign)) + (//i64.left_shifted ..mantissa_size (.i64 (//int.+ (.int ..double_bias) exponent))) (//i64.clear ..mantissa_size (.i64 mantissa)))))) (#try.Failure ("lux text concat" <error> representation))))))] diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index f11eee2f4..6ddd718ec 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -31,8 +31,8 @@ [(I64 Any) xor "lux i64 xor" "Bitwise xor."] [(I64 Any) and "lux i64 and" "Bitwise and."] - [Nat left_shift "lux i64 left-shift" "Bitwise left-shift."] - [Nat right_shift "lux i64 right-shift" "Unsigned/logic bitwise right-shift."] + [Nat left_shifted "lux i64 left-shift" "Bitwise left-shift."] + [Nat right_shifted "lux i64 right-shift" "Unsigned/logic bitwise right-shift."] ) (type: #export Mask @@ -40,7 +40,7 @@ (def: #export (bit position) (-> Nat Mask) - (|> 1 .i64 (..left_shift (n.% ..width position)))) + (|> 1 .i64 (..left_shifted (n.% ..width position)))) (def: #export sign Mask @@ -65,19 +65,19 @@ 0 ..false bits (case (n.% ..width bits) 0 ..true - bits (|> 1 .i64 (..left_shift (n.% ..width bits)) .dec)))) + bits (|> 1 .i64 (..left_shifted (n.% ..width bits)) .dec)))) (def: (add_shift shift value) (-> Nat Nat Nat) - (|> value (right_shift shift) (n.+ value))) + (|> value (right_shifted shift) (n.+ value))) (def: #export (count subject) {#.doc "Count the number of 1s in a bit-map."} (-> (I64 Any) Nat) - (let [count' (n.- (|> subject (right_shift 1) (..and 6148914691236517205) i64) + (let [count' (n.- (|> subject (right_shifted 1) (..and 6148914691236517205) i64) (i64 subject))] (|> count' - (right_shift 2) (..and 3689348814741910323) (n.+ (..and 3689348814741910323 count')) + (right_shifted 2) (..and 3689348814741910323) (n.+ (..and 3689348814741910323 count')) (add_shift 4) (..and 1085102592571150095) (add_shift 8) (add_shift 16) @@ -113,13 +113,13 @@ (..or (<forward> distance input) (<backward> (n.- (n.% ..width distance) ..width) input)))] - [rotate_left ..left_shift ..right_shift] - [rotate_right ..right_shift ..left_shift] + [left_rotated ..left_shifted ..right_shifted] + [right_rotated ..right_shifted ..left_shifted] ) (def: #export (region size offset) (-> Nat Nat Mask) - (..left_shift offset (..mask size))) + (..left_shifted offset (..mask size))) (implementation: #export equivalence (All [a] (Equivalence (I64 a))) @@ -149,7 +149,7 @@ (All [a] (-> (I64 a) (I64 a))) (let [swapper (: (-> Nat (All [a] (-> (I64 a) (I64 a)))) (function (_ power) - (let [size (..left_shift power 1) + (let [size (..left_shifted power 1) repetitions (: (-> Nat Text Text) (function (_ times char) (loop [iterations 1 @@ -164,10 +164,10 @@ (repetitions size "0"))) high (try.assumed (\ n.binary decode pattern)) - low (..rotate_right size high)] + low (..right_rotated size high)] (function (_ value) - (..or (..right_shift size (..and high value)) - (..left_shift size (..and low value))))))) + (..or (..right_shifted size (..and high value)) + (..left_shifted size (..and low value))))))) swap/01 (swapper 0) swap/02 (swapper 1) @@ -205,7 +205,7 @@ (def: &equivalence ..equivalence) (def: width width) (def: (narrow value) - (..or (|> value (..and ..sign) (..right_shift sign_shift)) + (..or (|> value (..and ..sign) (..right_shifted sign_shift)) (|> value (..and mantissa)))) (def: (widen value) (.i64 (case (.nat (..and sign value)) diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index b5806e0db..9724bc766 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -189,12 +189,12 @@ (def: &enum ..enum) (def: top ## +9,223,372,036,854,775,807 - (let [half (//i64.left_shift 62 +1)] + (let [half (//i64.left_shifted 62 +1)] (+ half (dec half)))) (def: bottom ## -9,223,372,036,854,775,808 - (//i64.left_shift 63 +1))) + (//i64.left_shifted 63 +1))) (template [<name> <compose> <identity>] [(implementation: #export <name> @@ -253,8 +253,8 @@ (def: &equivalence ..equivalence) (def: hash .nat)) -(def: #export (right_shift parameter subject) +(def: #export (right_shifted parameter subject) {#.doc "Signed/arithmetic bitwise right-shift."} (-> Nat Int Int) (//i64.or (//i64.and //i64.sign subject) - (//i64.right_shift parameter subject))) + (//i64.right_shifted parameter subject))) diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index 3ad54b2bd..c97849629 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -45,8 +45,7 @@ "The denominator can be omitted if it is 1." (ratio numerator))} (in (list (` ((~! ..normal) {#..numerator (~ numerator) - #..denominator (~ (maybe.default (' 1) - ?denominator))}))))) + #..denominator (~ (maybe.else (' 1) ?denominator))}))))) (def: #export (= parameter subject) (-> Ratio Ratio Bit) diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index 431f44ed1..72073f421 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -23,7 +23,7 @@ (template [<power> <name>] [(def: #export <name> Rev - (.rev (//i64.left_shift (//nat.- <power> //i64.width) 1)))] + (.rev (//i64.left_shifted (//nat.- <power> //i64.width) 1)))] [01 /2] [02 /4] @@ -118,12 +118,12 @@ ..high ("lux i64 +" top)))) -(def: even_one (//i64.rotate_right 1 1)) +(def: even_one (//i64.right_rotated 1 1)) (def: odd_one (dec 0)) (def: (even_reciprocal numerator) (-> Nat Nat) - (//nat./ (//i64.right_shift 1 numerator) + (//nat./ (//i64.right_shifted 1 numerator) ..even_one)) (def: (odd_reciprocal numerator) @@ -293,7 +293,7 @@ (def: (digits::get idx digits) (-> Nat Digits Nat) - (|> digits (array.read idx) (maybe.default 0))) + (|> digits (array.read idx) (maybe.else 0))) (def: digits::put (-> Nat Nat Digits Digits) |