diff options
Diffstat (limited to 'stdlib/source')
-rw-r--r-- | stdlib/source/lux/data/bit.lux | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/stdlib/source/lux/data/bit.lux b/stdlib/source/lux/data/bit.lux index 4e87a23dc..29b01e370 100644 --- a/stdlib/source/lux/data/bit.lux +++ b/stdlib/source/lux/data/bit.lux @@ -1,5 +1,7 @@ (;module: [lux #- and or not]) +(def: #export width Nat +64) + ## [Values] (do-template [<short-name> <op> <doc> <type>] [(def: #export (<short-name> param subject) @@ -7,18 +9,12 @@ (-> Nat <type> <type>) (_lux_proc ["bit" <op>] [subject param]))] - [and "and" - "Bitwise and." Nat] - [or "or" - "Bitwise or." Nat] - [xor "xor" - "Bitwise xor." Nat] - [shift-left "shift-left" - "Bitwise shift-left." Nat] - [shift-right "shift-right" - "Bitwise shift-right." Int] - [unsigned-shift-right "unsigned-shift-right" - "Bitwise unsigned-shift-right." Nat] + [and "and" "Bitwise and." Nat] + [or "or" "Bitwise or." Nat] + [xor "xor" "Bitwise xor." Nat] + [shift-left "shift-left" "Bitwise shift-left." Nat] + [shift-right "shift-right" "Bitwise shift-right." Int] + [unsigned-shift-right "unsigned-shift-right" "Bitwise unsigned-shift-right." Nat] ) (def: #export (count subject) @@ -52,14 +48,12 @@ (-> Nat Nat Bool) (|> input (;;and (shift-left idx +1)) (n.= +0) ;not)) -(def: rot-top Nat +64) - (do-template [<name> <main> <comp>] [(def: #export (<name> distance input) (-> Nat Nat Nat) (;;or (<main> distance input) - (<comp> (n.- (n.% rot-top distance) - rot-top) + (<comp> (n.- (n.% width distance) + width) input)))] [rotate-left shift-left unsigned-shift-right] |