我正在嘗試編寫一個函數,將一個元素添加到給定powerset的每個元素。無論它總是評估(null pset)爲真。我不明白爲什麼。如何將對象添加到LISP中列表的每個元素?
這是我到目前爲止有:
(defun addxtopowerset(x pset)
(cond
((null pset) (list x '())) ; If the powerset is null, display x and NIL.
;;First display a list combining x and the first item of pset. Then display the first item of pset itself. Then recursively call the function passing the rest of pset as a parameter.
(T (list 'x (car pset))(list (car pset))
(addxtopowersetch x (cdr pset)))))
那些'LIST'操作2和3。他們在做什麼?結果在哪裏?目前看起來結果直接進入了數字涅。。 –