on bfaa358 help sign in
57 lines 1.0 kB history raw
1### `++mug`
3Hashes `a` with the 31-bit nonzero FNV-1a non-cryptographic hash
4algorithm, producing an atom.
6Accepts
7-------
9A is a noun.
11Produces
12--------
14An atom.
16Source
17------
19 ++ mug :: 31bit nonzero FNV1a
20 ~/ %mug
21 |= a/*
22 ?^ a
23 =+ b=[p=$(a -.a) q=$(a +.a)]
24 |- ^- @
25 =+ c=(fnv (mix p.b (fnv q.b)))
26 =+ d=(mix (rsh 0 31 c) (end 0 31 c))
27 ?. =(0 c) c
28 $(q.b +(q.b))
29 =+ b=2.166.136.261
30 |- ^- @
31 =+ c=b
32 =+ [d=0 e=(met 3 a)]
33 |- ^- @
34 ?: =(d e)
35 =+ f=(mix (rsh 0 31 c) (end 0 31 c))
36 ?. =(0 f) f
37 ^$(b +(b))
38 $(c (fnv (mix c (cut 3 [d 1] a))), d +(d))
41Examples
42--------
44 ~zod/try=> (mug 10.000)
45 178.152.889
46 ~zod/try=> (mug 10.001)
47 714.838.017
48 ~zod/try=> (mug 1)
49 67.918.732
50 ~zod/try=> (mug (some 10))
51 1.872.403.737
52 ~zod/try=> (mug (limo [1 2 3 4 5 ~]))
53 1.067.931.605
57***