Raymond Toy pushed to branch issue-240-add-hashtable-set-exclusive-or at cmucl / cmucl

Commits:

2 changed files:

Changes:

  • src/code/list.lisp
    ... ... @@ -916,35 +916,36 @@
    916 916
                  (type function test test-not))
    
    917 917
         ;; Find the elements in list1 that do not appear in list2 and add
    
    918 918
         ;; them to the result.
    
    919
    -    (let ((hashtable (list-to-hashtable list2 key test test-not)))
    
    920
    -      (cond
    
    921
    -        (hashtable
    
    922
    -         (dolist (elt list1)
    
    923
    -           (unless (nth-value 1 (gethash (apply-key key elt) hashtable))
    
    924
    -             (setq result (cons elt result)))))
    
    925
    -        (t
    
    926
    -         (dolist (elt list1)
    
    927
    -           (unless (with-set-keys (member (apply-key key elt) list2))
    
    928
    -	     (setq result (cons elt result)))))))
    
    929
    -    ;; Now find the elements in list2 that do not appear in list1 and
    
    930
    -    ;; them to the result.
    
    931
    -    (let ((hashtable (list-to-hashtable list1 key test test-not)))
    
    932
    -      (cond
    
    933
    -        (hashtable
    
    934
    -         (dolist (elt list2)
    
    935
    -           (unless (nth-value 1 (gethash (apply-key key elt) hashtable))
    
    936
    -             (setq result (cons elt result)))))
    
    937
    -        (t
    
    938
    -         (let ((test (if testp
    
    939
    -                         (lambda (x y) (funcall test y x))
    
    940
    -                         test))
    
    941
    -               (test-not (if notp
    
    942
    -                             (lambda (x y) (funcall test-not y x))
    
    943
    -                             test-not)))
    
    944
    -           (dolist (elt list2)
    
    945
    -             (unless (with-set-keys (member (apply-key key elt) list1))
    
    946
    -               (setq result (cons elt result))))))))
    
    947
    -    result))
    
    919
    +    (macrolet
    
    920
    +        ((compute-membership (item-list test-form)
    
    921
    +           `(dolist (elt ,item-list)
    
    922
    +              (unless ,test-form
    
    923
    +                (setq result (cons elt result))))))
    
    924
    +      (let ((hashtable (list-to-hashtable list2 key test test-not)))
    
    925
    +        (cond
    
    926
    +          (hashtable
    
    927
    +           (compute-membership list1
    
    928
    +                               (nth-value 1 (gethash (apply-key key elt) hashtable))))
    
    929
    +          (t
    
    930
    +           (compute-membership list1
    
    931
    +                               (with-set-keys (member (apply-key key elt) list2))))))
    
    932
    +      ;; Now find the elements in list2 that do not appear in list1 and
    
    933
    +      ;; them to the result.
    
    934
    +      (let ((hashtable (list-to-hashtable list1 key test test-not)))
    
    935
    +        (cond
    
    936
    +          (hashtable
    
    937
    +           (compute-membership list2
    
    938
    +                               (nth-value 1 (gethash (apply-key key elt) hashtable))))
    
    939
    +          (t
    
    940
    +           (let ((test (if testp
    
    941
    +                           (lambda (x y) (funcall test y x))
    
    942
    +                           test))
    
    943
    +                 (test-not (if notp
    
    944
    +                               (lambda (x y) (funcall test-not y x))
    
    945
    +                               test-not)))
    
    946
    +             (compute-membership list2
    
    947
    +                                 (with-set-keys (member (apply-key key elt) list1)))))))
    
    948
    +      result)))
    
    948 949
     
    
    949 950
     
    
    950 951
     ;;; The outer loop examines list1 while the inner loop examines list2. If an
    

  • src/i18n/locale/cmucl.pot
    ... ... @@ -3236,7 +3236,7 @@ msgid "Destructively returns the elements of list1 which are not in list2."
    3236 3236
     msgstr ""
    
    3237 3237
     
    
    3238 3238
     #: src/code/list.lisp
    
    3239
    -msgid "Return new list of elements appearing exactly once in LIST1 and LIST2."
    
    3239
    +msgid "Return new list of elements appearing exactly one of LIST1 and LIST2."
    
    3240 3240
     msgstr ""
    
    3241 3241
     
    
    3242 3242
     #: src/code/list.lisp