Skip to content

Instantly share code, notes, and snippets.

@frodwith
Created July 3, 2020 20:43
Show Gist options
  • Save frodwith/af85cc410ac52beee0ec0b87917e102e to your computer and use it in GitHub Desktop.
Save frodwith/af85cc410ac52beee0ec0b87917e102e to your computer and use it in GitHub Desktop.
mung, a replacement for mug?
:- %say
|= [* ~ *]
:- %noun
=< ^- (list @uv)
%- turn
:_ mung
^- (list *)
:~ 0
42
[0 0]
[1 1]
[[1 2] 1 2]
[[2 1] 1 2]
-:post
==
|%
++ post
:: arbitrary atom to 31-bit non-zero value
|= a=@
^- @
.+ (end 0 30 a)
++ mux
:: noun merkle hash from arbitrary atom hash
|= [noun=* bits=@ hash=$-(@ @)]
^- @
%- hash
?@ noun noun
%+ con $(noun -.noun)
%^ lsh 0 bits
$(noun +.noun)
++ mung
:: 31-bit non-zero murmur3-32 based merkle hash
|= noun=*
^- @
%^ mux noun 31
|= a=@
%- post
(muk 0xcafe.babe (met 3 a) a)
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment