Lisphw3 - T(memset(car lis1 lis2(eqset(cdr lis1 lis2 Sheet1 Page 2 nil(defun unnest(lis(cond(null lis nil(not(atom(car lis(unnest(car lis

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 (defun len(lis) (cond ((null lis) 0 ) ( 'else (+ (len(cdr lis)) 1)) )) LEN > (len '(A B C)) 3 > (len '(A B (DS dsf sdf) (asdf f ds) (AAS) (asd (sada sadD)) )) 6 > (defun union1 (Set1 Set2) (cond ( (null Set1) Set2) ( (memset (car Set1) Set2) (union (cdr Set1) Set2) ) ( 'otherwise (cons (car Set1) (union (cdr Set1) Set2))) )) UNION1 (defun memset (S1 Set) (cond ( (null Set) nil) ( (equal S1 (car Set)) Set) ( (memset S1 (cdr Set))) )) makest (defun makeset (lis) (cond ((null lis) nil) ((memset (car lis) (cdr lis)) (makeset (cdr lis))) (T (cons (car lis) (makeset (cdr lis)))) )) (defun setdiff(lis1 lis2) (cond ((null lis1) nil) ( (memset (first lis1) lis2) (setdiff (cdr lis1) lis2) ) ( T (cons (car lis1) (setdiff (cdr lis1) lis2) ) ) )) (defun eqset(lis1 lis2) (cond ( (and (null lis1) (null lis1))
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: T ) ( (memset (car lis1) lis2) (eqset (cdr lis1) lis2) ) Sheet1 Page 2 ( nil ) )) (defun unnest(lis) (cond ((null lis) nil) ( (not(atom (car lis))) (unnest(car lis) ) ) ( T (cons (car lis) (unnest(cdr lis)) ) ) )) (defun unnest(lis) (cond ((null lis) nil) ( (and (not(atom (car lis))) (null(cdr lis)) ) (unnest(car lis) ) ) ( (and (not(atom (car lis))) (not(null(cdr lis))) ) (unnest(cdr lis) ) ) ( T (cons (car lis) (unnest(cdr lis)) ) ) )) (defun unnest(lis) (cond ((null lis) nil) ( (and (not(atom (car lis))) (null(cdr lis)) ) (unnest(car lis)) ) ( (and (not(atom (car lis))) (not(null(cdr lis))) ) (cons (unnest(car lis)) (unnest(cdr lis)) ) ) ( T (cons (car lis) (unnest(cdr lis)) ) ) ))...
View Full Document

This note was uploaded on 09/17/2009 for the course EEL 5840 taught by Professor Arroyo during the Fall '08 term at University of Florida.

Page1 / 2

Lisphw3 - T(memset(car lis1 lis2(eqset(cdr lis1 lis2 Sheet1 Page 2 nil(defun unnest(lis(cond(null lis nil(not(atom(car lis(unnest(car lis

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online