<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Bulat,<br><br>I was just looking for a simple hashing function. I was going to use the length function but a constant int is even simpler.&nbsp; I'm supposing that had I used the length function "mike" and "fred" would end up in the same bucket.<br><br>This is the first time I've tried to do anything in Haskell with data structures other than lists, so I needed to see how things work.<br><br>Thanks, everyone, for the help.<br><br>Michael<br><br>--- On <b>Tue, 11/17/09, Bulat Ziganshin <i>&lt;bulat.ziganshin@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Bulat Ziganshin &lt;bulat.ziganshin@gmail.com&gt;<br>Subject: Re[2]: [Haskell-cafe] Simple hash table creation<br>To: "michael rice" &lt;nowgate@yahoo.com&gt;<br>Cc: "Gregory Crosswhite"
 &lt;gcross@phys.washington.edu&gt;, haskell-cafe@haskell.org<br>Date: Tuesday, November 17, 2009, 4:38 PM<br><br><div class="plainMail">Hello michael,<br><br>Wednesday, November 18, 2009, 12:00:58 AM, you wrote:<br><br>*Main&gt;&gt; toList ht<br>&gt; [("miguel",3),("michael",2),("mike",1)] <br>&gt;<br>&gt; It seems my dummy function is being ignored.<br><br>i wonder why you think so?<br><br>your ht has all 3 pairs you ever inserted<br><br>inside, they all are inside the same bucket since hash function<br>returns the same value for them<br><br>... hmm, i guess that you expect something like low-level hashtable<br>from other languages - i.e. it should have just one slot for all<br>values hashed to 7 and save here last value<br><br>it works other way - it has just one slot for all your values but it<br>stores here LIST of your pairs. so nothing is lost. if you want to<br>save only the last value, replace (==) to (\a b -&gt; dummy a==dummy b)<br><br>the
 whole story is that hash function used to select slot, and then<br>key part of pair is compared using (==) with keys of all values in the<br>slot. it will replace existing pair if key1==key2, otherwise added to<br>list<br><br>so, hashing allows to quickly find pair by its key, but it still full<br>map as far as you pass a usual (==)<br><br>-- <br>Best regards,<br> Bulat&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mailto:<a ymailto="mailto:Bulat.Ziganshin@gmail.com" href="/mc/compose?to=Bulat.Ziganshin@gmail.com">Bulat.Ziganshin@gmail.com</a><br><br></div></blockquote></td></tr></table><br>