Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 236147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:19:18+00:00 2026-05-11T20:19:18+00:00

I’m working on a p2p app that uses hash trees. I am writing the

  • 0

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

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:19:19+00:00Added an answer on May 11, 2026 at 8:19 pm

    Looking at your code I can see one issue that would generate that particular exception error

    publ_top(_,[],Accumulated,Level) ->
        %% Go through the accumulated list of hashes from the prior level
        publ_top(string:len(Accumulated),Accumulated,[],Level+1);
    
    publ_top(FullLevelLen,RestofLevel,Accumulated,Level) ->
      case FullLevelLen =:= 1 of
        false -> [F,S|T]=RestofLevel,
          io:format("~w---~w~n",[F,S]),
          publ_top(FullLevelLen,T,lists:append(Accumulated,[erlang:phash2(string:concat([F],[S]))]),Level);
        true -> done
      end.
    

    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 when FullLevelLen is different from 1 and RestOfLevel is 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:

    publ_top(_,[],Accumulated,Level) ->
        %% Go through the accumulated list of hashes from the prior level
        publ_top(string:len(Accumulated),Accumulated,[],Level+1);
    
    publ_top(1, _, _, _) ->
        done;
    
    publ_top(_, [F,S|T], Accumulated, Level) ->
        io:format("~w---~w~n",[F,S]),
        publ_top(FullLevelLen,T,lists:append(Accumulated,[erlang:phash2(string:concat([F],[S]))]),Level);
    
    %% Missing case:
    % publ_top(_, [H], Accumulated, Level) ->
    %     ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.