No matching definitions.

tur/hash

stdlib/hash.tur

canonical integer hashing across numeric widths.

Signed narrow types sign-extend to :int before hashing, so (= (hash-int8 n) (hash-int (as int n))) holds for any valid int8 n. Unsigned narrow types zero-extend, so (hash-uint8 255u8) differs from (hash-int -1) even though both share the same 8-bit pattern.

Hash function: splitmix64 finalizer (bijective, avalanche-complete).

Since: Phase C

defn

hash-int

(hash-int [n :int] :int)

hash a 64-bit signed integer via splitmix64 finalizer.

nvalue to hash

A 64-bit hash of n as :int.

(hash-int 42)  ; => some stable 64-bit integer

Since: Phase C

defn

hash-int8

(hash-int8 [n :int8] :int)

hash an int8; equals (hash-int (as int n)) via sign-extension.

nint8 value to hash

Same as (hash-int (as int n)).

(= (hash-int8 42i8) (hash-int 42))  ; => true

Since: Phase C

defn

hash-int16

(hash-int16 [n :int16] :int)

hash an int16; equals (hash-int (as int n)) via sign-extension.

nint16 value to hash

Same as (hash-int (as int n)).

(= (hash-int16 1000i16) (hash-int 1000))  ; => true

Since: Phase C

defn

hash-int32

(hash-int32 [n :int32] :int)

hash an int32; equals (hash-int (as int n)) via sign-extension.

nint32 value to hash

Same as (hash-int (as int n)).

(= (hash-int32 100000i32) (hash-int 100000))  ; => true

Since: Phase C

defn

hash-int64

(hash-int64 [n :int64] :int)

hash an int64; identical to hash-int.

nint64 value to hash

Same as (hash-int (as int n)).

(= (hash-int64 42i64) (hash-int 42))  ; => true

Since: Phase C

defn

hash-uint8

(hash-uint8 [n :uint8] :int)

hash a uint8 via zero-extension to :int.

A uint8 value of 0xFF (255) produces a different hash than :int -1, since zero-extension gives 255, not 0xFFFFFFFFFFFFFFFF.

nuint8 value to hash

Same as (hash-int (as int n)) where (as int n) zero-extends.

(not= (hash-uint8 255u8) (hash-int -1))  ; => true

Since: Phase C

defn

hash-uint16

(hash-uint16 [n :uint16] :int)

hash a uint16 via zero-extension to :int.

nuint16 value to hash

Same as (hash-int (as int n)) where (as int n) zero-extends.

(= (hash-uint16 1000u16) (hash-int 1000))  ; => true

Since: Phase C

defn

hash-uint32

(hash-uint32 [n :uint32] :int)

hash a uint32 via zero-extension to :int.

nuint32 value to hash

Same as (hash-int (as int n)) where (as int n) zero-extends.

(= (hash-uint32 1000u32) (hash-int 1000))  ; => true

Since: Phase C

defn

hash-uint64

(hash-uint64 [n :uint64] :int)

hash a uint64 by reinterpreting as :int then hashing.

nuint64 value to hash

Hash of the 64-bit bit pattern of n.

(hash-uint64 0u64)  ; => same as (hash-int 0)

Since: Phase C