Created
April 6, 2019 14:44
-
-
Save paniq/bbe6610d4e61b527eef45c866c3825d6 to your computer and use it in GitHub Desktop.
This file contains 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
using import Array | |
let C = | |
import-c "lib.c" | |
""""int printf (const char *fmt, ...); | |
'() | |
let SerialArray = (GrowingArray hash) | |
let salt = (hash "a bit of salt") | |
run-stage; | |
fn print-serial (i x) | |
x := x as u64 | |
block1 := x & 0xffff:u64 | |
block2 := x >> 16:u64 & 0xffff:u64 | |
block3 := x >> 32:u64 & 0xffff:u64 | |
block4 := x >> 48:u64 & 0xffff:u64 | |
C.printf "%4i: %04llX-%04llX-%04llX-%04llX\n\n" i | |
block1 | |
block2 | |
block3 | |
block4 | |
fn print-serials (last N) | |
local serials : SerialArray | |
fold (last = last) for i in (range N) | |
let newval = | |
hash salt last | |
'append serials newval | |
newval | |
'sort serials | |
inline (key) | |
key as u64 | |
for i entry in (enumerate serials) | |
print-serial i entry | |
print-serials (hash "seed string") 16 | |
; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment