COMBINE will consider NIL as other symbols as the singleton containing them, instead of the empty set.

Pascal J. Bourguignon [2020-10-28 07:12]
COMBINE will consider NIL as other symbols as the singleton containing them, instead of the empty set.
Filename
common-lisp/cesarum/list.lisp
diff --git a/common-lisp/cesarum/list.lisp b/common-lisp/cesarum/list.lisp
index 1778775..e125e9b 100644
--- a/common-lisp/cesarum/list.lisp
+++ b/common-lisp/cesarum/list.lisp
@@ -600,8 +600,14 @@ EXAMPLE: (COMBINE '(WWW FTP) '(EXA) '(COM ORG)))
            --> ((WWW EXA COM) (WWW EXA ORG) (FTP EXA COM) (FTP EXA ORG))
 "
   (cond
-    ((null args)        '(nil))
-    ((null  (car args)) (apply (function combine) (cdr args)))
+    ((null args)        '(()))
+
+    ;; Don't consider empty set for one of the arguments since the combination
+    ;; should produce the empty set:
+    ;; {} x {1,2} = {}
+    ;; Instead, let it fall to the default case, considering it as the symbol NIL.
+    ;; ((null  (car args)) (apply (function combine) (cdr args)))
+
     ((consp (car args)) (mapcan (lambda (item)
                                   (apply (function combine) item (cdr args)))
                                 (car args)))
ViewGit