写一个保留原本列表中元素顺序的 union 版本:
> (new-union '(a b c) '(b a d)) (A B C D)
CL-USER> (defun our-union (fi la) (and (listp fi) (listp la) (let (( res (reverse fi))) (dolist (elt la) (pushnew elt res)) (reverse res)))) STYLE-WARNING: redefining COMMON-LISP-USER::OUR-UNION in DEFUN OUR-UNION CL-USER> (our-union '(a b c) '(b a d)) (A B C D) CL-USER> (our-union 'a '(b a d)) NIL CL-USER> (our-union '(a b) 'a) NIL CL-USER> (our-union '(a b) 'a) NIL |
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/133735/viewspace-740221/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/133735/viewspace-740221/