Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rpi!crdgw1!vdsvax!montnaro From: montnaro@sprite.crd.ge.com (Skip Montanaro) Newsgroups: gnu.emacs.lisp.manual Subject: Correction to ELisp address, union/intersect examples Message-ID: Date: 28 Apr 89 16:51:02 GMT Sender: news@vdsvax.steinmetz.ge.com Reply-To: (Skip Montanaro) Distribution: gnu Organization: GE Corporate Research & Development, Schenectady, NY Lines: 65 In article bob@allosaur.cis.ohio-state.edu (Bob Sutterfield) writes: OK, I think we're up to date again now... I just put the new Emacs Lisp manual in place on osu-cis and updated GNU.how-to-get. In what I think is the latest INFO-ized version of the ELisp manual, the comment/corretion address is incorrect. Maybe we're "not quite up-to-date". :-) I quote from file elisp-1: Mail comments and corrections to: gnu.emacs.lisp.manual@prep.ai.mit.edu -Bil Lewis 31-Oct-87 -Dan LaLiberte 01-Apr-89 According to the aliases file on rice-chex, it should be gnu-manual@prep.ai.mit.edu Perhaps the address was correct in the texinfo source, but got mangled somehow in the texinfo->info process? Changing the subject entirely, here are sample union/intersect functions. They were solicited in the Lisp manual section on using lists as sets. The functions below are not too robust, since they don't check their args for list-hood or nil-ness. They're just part of a throwaway prototype, but demonstrate the idea. (defun union (a b) "merge lists A and B together, eliminating duplicates (boolean set or)." (let ((l nil) (both (append a b))) (while both (setq l (append l (list (car both)))) (setq both (delete (car both) both))) l)) (defun intersect (a b) "merge lists A and B together, retaining only elements they have in common (boolean set and)." (let ((l nil)) (while a (if (contains (car a) b) (progn (setq b (delete (car a) b)) (setq l (append l (list (car a)))))) (setq a (cdr a))) l)) They both use delete (could use delq if eql comparison is good enough for you): (defun delete (e l) "Delete E from list L. Uses 'equal for comparison." (let ((n nil)) (while l (if (not (equal e (car l))) (setq n (append n (list (car l))))) (setq l (cdr l))) n)) -- Skip Montanaro (montanaro@sprite.crd.ge.com)