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
function bitarr_to_int(arr, val = 0) | |
v = 2^(length(arr)-1) | |
for i in eachindex(arr) | |
val += v*arr[i] | |
v >>= 1 | |
end | |
return val | |
end | |
function bitvec_to_pos(bvec) |
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
import Pkg | |
import Base: SHA1 | |
using SHA, UUIDs | |
function uuid5(namespace::UUID, key::String) | |
data = [reinterpret(UInt8, [namespace.value]); codeunits(key)] | |
u = reinterpret(UInt128, sha1(data)[1:16])[1] | |
u &= 0xffffffffffff0fff3fffffffffffffff | |
u |= 0x00000000000050008000000000000000 | |
return UUID(u) |