Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
As it was my explanation in chatter that inspired this obfuscation, here is a quick explanation.

A hashing function is a function that takes input (usually a string) and gives back a number in some range.

A hash lookup algorithm takes keys, passes the keys to a hashing function, and then uses that number to select a bucket, then stores the key/value in the bucket in some way. Hopefully the keys are pretty much randomly distributed so each bucket has few things in it. Details vary, there are different hashing algorithms you can use, different ways to store things in buckets, often there is some dynamic decision on how many buckets to use, etc.

Perl's hashes are called hashes because they use a hash lookup algorithm to store data. That is why lookups are fast. But when you ask for them back (with keys or values) it just walks the buckets, and returns things out of the buckets. The order you get back depends on all sorts of things, starting with the hashing function and number of buckets...

As a test, anyone who can understand Re: Re: Shift, Pop, Unshift and Push with Impunity! probably understood this explanation perfectly.

Anyways, the order that stuff comes back is entirely determined by internal details, looks random, but isn't. So if you figure out what order keys will give for (for instance) a series of numbers, then just put the values in matched to where you want them to go and voila! You get output sorted from values just right for no apparent reason! :-)


In reply to Re (tilly) 4: Flip Flop III - Musical Buckets by tilly
in thread Flip Flop III - Musical Buckets by MeowChow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-28 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found