Handbook
Glossary
sequence-hashcode ( depth seq -- x )
Vocabulary
sequences
Inputs
depth
an
integer
seq
a
sequence
Outputs
x
an
integer
Word description
Iterates over a sequence, computes a hashcode with
hashcode*
for each element, and combines them using fixnum arithmetic. Both the element order and the sequence length contribute to the hash.
Definition
USING:
kernel
math
math.private
;
IN:
sequences
:
sequence-hashcode
( depth seq -- x )
[
1000003 3430008
]
2dip
[
length
integer>fixnum
dup
fixnum+fast
82520
fixnum+fast
swap
]
keep
[
hashcode*
integer>fixnum
rot
fixnum-bitxor
pick
fixnum*fast
[
[
fixnum+fast
]
keep
]
dip
swap
]
with
each
drop
nip
97531
fixnum+fast
;
inline