@ifplaintext
\input texinfo
@settitle Lex1, a hashed name-value store
@setfilename lex1.txt
@copying
This manual is for workspace assert version  0 1 2.

Copyright @copyright{} 2019 Bill Daly

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
@end copying

@titlepage
@title Lex1, a hashed name-value store
@author Bill Daly

@end titlepage

@ifnottex
@node TOP
@end ifnottex

@end ifplaintext

@ifnotplaintext
@node lex1
@end ifnotplaintext

@chapter Lex1, a hashed name-value store
@cindex lex1
@cindex hash tables

Lex1 is an implementation of a name-value store for apl using a
hash. Functions here allow one to create such a store, add name and
retrieve a value for a name.

Functions are

@deffn ∇ lex ← lex1∆init

Returns an empty store.
@end deffn

@deffn ∇ lex ← lex lex1∆assign name--value

Returns a hash with the supplied name--value inserted into the supplied lexicon.

@end deffn

@deffn ∇ lex ← lex lex1∆lookup name

Returns the value of the supplied name.

@end deffn

@deffn ∇ boolean ← lex1∆is lex

Predicate to return true if the supplied item is in fact a
  lexicon.

@end deffn

@deffn ∇ array ← lex1∆keys lex

Returns the list of names in the supplied lexicon.

@end deffn

@deffn ∇ array ← lex1∆values lex

Returns a list of values in the supplied lexicon.
@end deffn

@deffn ∇ int ← lex1∆hashPrime lex key

Returns a bucket number mapped to the supplied key.
@end deffn

@deffn ∇ array ← lex1∆distribution lex

Returns the number of items in each bucket.
@end deffn

We use @code{⎕io+prime|+/⎕ucs key} to compute the hash. It has
two features:

@itemize @bullet
@item Its result is fixed and determinable for any key.
@item It will yield an index into the hash.
@end itemize

