You are on page 1of 1

;;; Recursivdsfvzxc/tutorial1.

html
vcxzcv vsc xz
(is-in k (rest L)))))
(defun appendi(L1 L2)
;; append L2 to L1
(if (null L1)
L2
(cons (first L1) (appendi (rest L1) L2))))
(defun but-last(L)
xzcv k in L
(cond
((null L) 0)
((equal (first L) k)
(1+ (counter k (rest L))))
(t (counter k (rest L)))))
(defun list-inters(L1 L2)
;; intersection between L1 L2
(condxzcv
((is-in (first L1) L2)
(cons (first L1) (list-inters (rest L1) L2)))
(t
(list-inters (rest L1) L2)) ))
(defun list-union (L1 L2)
;; act as the built-in *union*
(cond
((null L1) L2)
((not (is-in (first L1) L2)) ;if L1[n] not in L2
(cons (first L1) (list-union (rest L1) L2))) ;append L1[n] to *recursion*
(t (list-union (rest L1) L2))))
(defun list-difference (L1 L2)
;; difference L1-L2 in sets
(cond
((null L1) nil)
((not(is-in (first L1) L2))
(cons (first L1) (list-difference (rest L1) L2)))
(t (list-difference (rest L1) L2)) ))

You might also like