This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: ) nil ) ) 6) Answer: a) Yes, any list of naturals such as (), (1), (4 5 8 10) . .. b) Yes, ((1 2) 1 a 2 b) c) Yes, (a 1 2) 7) Answer: (defun collect-dups (x) (if (consp x) (if (mem (first x) (rest x)) (cons (first x) (collect-dups (del* (first x) (rest x)) ) ) (collect-dups (rest x)) ) nil ) ) Here I used (del* e x) from Q88 By the way, this function might also be defined in a way that collects A twice because it appears 3 times: (collect-dups '(a b c a b a d e f)) ==> (a b a) 8) (defun find-pos-n (a x n) (if (endp x) n (if (equal a (first x)) n (find-pos-n a (rest x) (+ n 1)) ) ) ) (defun fine-pos (a x) (find-pos-n (a x 0) ) 9) Answer: (implies (or (e mem x) (e mem x) ) (e mem (app x y)) ) Here I used functions (app x y) from Q89 and (mem e x) from Q84....
View Full Document
This note was uploaded on 11/30/2010 for the course CS 313K taught by Professor Boyer during the Spring '08 term at University of Texas at Austin.
- Spring '08