I’m working on a p2p app that uses hash trees.
I am writing the hash tree construction functions (publ/4 and publ_top/4) but I can’t see how to fix publ_top/4.
I try to build a tree with publ/1:
nivd:publ("file.txt").
prints hashes...
** exception error: no match of right hand side value [67324168]
in function nivd:publ_top/4
in call from nivd:publ/1
The code in question is here:
http://github.com/AndreasBWagner/nivoa/blob/886c624c116c33cc821b15d371d1090d3658f961/nivd.erl
Where do you think the problem is?
Thank You,
Andreas
Looking at your code I can see one issue that would generate that particular exception error
In the first function declaration you match against the empty list. In the second declaration you match against a list of length (at least) 2 (
[F,S|T]). What happens whenFullLevelLenis different from 1 andRestOfLevelis a list of length 1? (Hint: You’ll get the above error).The error would be easier to spot if you would pattern match on the function arguments, perhaps something like: