<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title></title>
<META http-equiv=Content-Type content="text/html; charset=koi8-r">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
body {
  margin: 5px 5px 5px 5px;
  background-color: #ffffff;
}
/* ---------- Text Styles ---------- */
hr { color: #000000}
body, table /* Normal text */
{
 font-size: 15pt;
 font-family: 'Consolas';
 font-style: normal;
 font-weight: normal;
 color: #000000;
 text-decoration: none;
}
span.rvts1 /* Heading */
{
 font-size: 10pt;
 font-family: 'Arial';
 font-weight: bold;
 color: #0000ff;
}
span.rvts2 /* Subheading */
{
 font-size: 10pt;
 font-family: 'Arial';
 font-weight: bold;
 color: #000080;
}
span.rvts3 /* Keywords */
{
 font-size: 10pt;
 font-family: 'Arial';
 font-style: italic;
 color: #800000;
}
a.rvts4, span.rvts4 /* Jump 1 */
{
 font-size: 10pt;
 font-family: 'Arial';
 color: #008000;
 text-decoration: underline;
}
a.rvts5, span.rvts5 /* Jump 2 */
{
 font-size: 10pt;
 font-family: 'Arial';
 color: #008000;
 text-decoration: underline;
}
span.rvts6
{
 font-size: 8pt;
 font-family: 'arial';
 font-style: italic;
 color: #c0c0c0;
}
a.rvts7, span.rvts7
{
 font-size: 8pt;
 font-family: 'arial';
 color: #0000ff;
 text-decoration: underline;
}
/* ---------- Para Styles ---------- */
p,ul,ol /* Paragraph Style */
{
 text-align: left;
 text-indent: 0px;
 padding: 0px 0px 0px 0px;
 margin: 0px 0px 0px 0px;
}
.rvps1 /* Centered */
{
 text-align: center;
}
--></style>
</head>
<body>

<p>Hello haskell-cafe,</p>
<p><br></p>
<p>solving one more task that uses English dictionary, i've thought: why we don't yet have pure hashtable library? There is imperative hashtables, pretty complex as they need to rebuild entire table as it grows. There is also simple assoc lists and tree/trie implementations, but there is no simple non-modifiable hashes.</p>
<p><br></p>
<p>how should it look:</p>
<p>* hashtable is represented as an array of assoc lists: Array Int [(a,b)]</p>
<p><br></p>
<p>* interface to extract data from ht is the same as from assoc list:</p>
<p>lookup :: HT a b -&gt; a -&gt; Maybe b</p>
<p><br></p>
<p>* ht may be built from assoc list. we should just know it's size beforehand in order to create Array of reasonable size. constructor also need a hashing function:</p>
<p><br></p>
<p>create :: [(a,b)] -&gt; Int -&gt; (a-&gt;Int) -&gt; HT a b</p>
<p><br></p>
<p><br></p>
<p>given these constraints, it should be just a 10-20 lines of code, and provide much better efficiency than any tree/trie implementations</p>
<p><br></p>
<p><br></p>
<p><span class=rvts6>--&nbsp;</span></p>
<p><span class=rvts6>Best regards,</span></p>
<p><span class=rvts6>&nbsp;Bulat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><a class=rvts7 href="mailto:Bulat.Ziganshin@gmail.com">mailto:Bulat.Ziganshin@gmail.com</a></p>

</body></html>