The 'hash' function computes and returns an integer index for a given symbol 'name' and a given size of hash table 'table-size'. The intention is for 'hash' to be used with tables made by make-array and accessed by aref.
(hash "zzzz" 1000) ; returns index 322 (hash "ZZZZ" 1000) ; returns index 626 (hash 'ZZZZ 1000) ; returns index 626 (hash "hiho" 1000) ; returns index 519 (hash 'hiho 1000) ; returns index 143 (hash "abcd" 1000) ; returns index 72 ;; create a function to look inside *OBARRAY* and ;; look for a specific symbol - returns a list (defun lookin (sym) (aref *obarray* (hash sym (length *obarray*)))) (lookin 'caar) ; returns the hash table entry ; (ZEROP CDDDDR CAAR HASH)
Note: This is a useful function for creating and accessing tables. It is also useful for looking inside of XLISP's own symbol table *obarray*.
See the
hash
function in the