XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

hash


Type:   -   function (subr)
Source:   -   xlbfun.c, xlsym.c

Syntax

(hash name table-size)
name - a symbol or string expression
table-size - an integer expression
returns - the hash index as an integer value

Description

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.

Examples

(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 XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next