home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / lisp / lispnews / text0153.txt < prev    next >
Encoding:
Text File  |  1985-11-10  |  958 b   |  28 lines

  1. The function 'insert' in Opus 38.50 does not perform as advertised in 
  2. the manual if the last argument is non-nil (i.e. if no duplicates are allowed.
  3. It still insists on putting the duplicate element into the list. The
  4. fix is in /usr/lib/lisp/common2.l. Just change the default setting
  5. of the 'comparefn' to that given below instead of 
  6. (function alphalessp). Here is an excerpt from the modified file.
  7.  
  8.  
  9.   [.....]
  10. (def insert
  11.      (lambda (x l comparefn nodups)
  12.       (cond ((null l) (list x))
  13.             ((atom l)
  14.              (error "an atom, can't be inserted into" l))
  15.             (t (cond
  16.                 ((null comparefn) (setq comparefn 
  17.                     (function
  18.                      (lambda (x y) 
  19.                          (or (alphalessp x y) 
  20.                              (equal x y)))))))
  21.                (prog (l1 n n1 y)
  22.                      (setq l1 l)
  23.                      (setq n (length l))
  24.                 a    (setq n1 (/ (add1 n) 2))
  25.                      (setq y (Cnth l1 n1))
  26.              [..........]
  27.  
  28.