Created
July 18, 2024 15:08
-
-
Save paniq/655941302aa0b278487b10e03ec0b416 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn bitstripes (n) | |
-1:u64 // ((1:u64 << n) | 1) | |
fn logleveld (x) | |
findmsb x | |
fn tt->anf (x) | |
w := (x == 0) 0 (logleveld x) | |
S := (logleveld w) + 1 | |
x := fold (x) for i in (range S) | |
w := 1:u64 << i | |
M0 := bitstripes w | |
M1 := M0 << w | |
k := x & M0 | |
k | ((x & M1) ^ (k << w)) | |
pass x S | |
fn anf->tt (x S) | |
fold (x) for i in (rrange S) | |
w := 1:u64 << i | |
M0 := bitstripes w | |
M1 := M0 << w | |
k := x & M0 | |
k | ((x & M1) ^ (k << w)) | |
for x in (range 256:u64) | |
y S := tt->anf x | |
x2 := anf->tt y S | |
/nolines | |
/bin x | |
/anf y | |
assert (x == x2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment