Question: I need hlp with these assignment. It is a lisp assgnment the one really need is from question 1 trough 13. thank you 8. Without

 I need hlp with these assignment. It is a lisp assgnment

I need hlp with these assignment. It is a lisp assgnment the one really need is from question 1 trough 13. thank you

8. Without using MEMBER, complete the following definition of a recursive function POS such that if L is a list and E is an element ofL then (POS E L) returns the position of the first occurrence of E in L, and such that E is not an element ofL then (POS E L) returns 0 (DEFUN POS (E L) (COND ((ENDP L (EQUAL E (CAR L)) (T (LET (X (POSE (CDRL)))) (POS 5 "( 1 2 5 3 5 5 1 5))-> 3 (POS 'A "(3 2 1))-> 0 (POS(3B) '(3 B))-> 0 Examples: (POS (A B) ((K) (3 RC) A (A B) (KL L) (A B))-4 (POS (3 B)3 B)-1 9. Define a recursive function SPLIT-NUMS such that if N is a non-negative integer then (SPLIT-NUMS N) returns a list of two lists: The first of the two lists consists of the even integers between 0 and N in descending order, and the other list consists of the odd integers between 0 and N in descending order. Examples: (SPLIT-NUMS 0)((O) NIL) (SPLIT-NUMS7)-> ((6 4 2 0) (7 5 3 1)) (SPLIT-NUMS 8)-> ((8 6 4 2 0) (7 5 3 1)) IMPORTANT: In problems 10- 13 the term set is used to mean a proper list of numbers and/or symbols in which no atom occurs more than once You may use MEMBER but not the functions UNION, NUNION, REMOVE, DELETE, SET-DIFFERENCE, and SET-EXCLUSIVE-OR. 10. Define a recursive function SET-UNION such that if s1 and s2 are sets then (SET-UNION s1 s2) is a set that contains the elements of sl and the elements of s2, but no other elements. Thus (SET-UNION (A BCD) (C E F)) should return a list consisting of the atoms A, B, C, D, E, and F (in any order) in which no atom occurs more than once. 11. Define a recursive function SET-REMOVE such that if s is a set and x is an atom in s then (SET-REMOVE x s) is a set that consists of all the elements of s except x, but if s is a set and x is an atom which is not in s then (SET-REMOVE x s) returns a set that is equal to s. In problems 12 and 13 you may use the function SET-REMOVE from problem 11. 12. Define a recursive function SET-EXCL-UNION such that if sl and s2 are sets then (SET-EXCL-UNION s1 s2) is a set that contains all those atoms that are elements of exactly one of sl and s2, but no other atoms. (SET-EXCL-UNION sl s2) does not contain any atoms that are neither in sl nor in s2, and also does not contain the atoms that are in both of sl and s2. For example, (SET-EXCL-UNION'(ABCD) ECFG A)) should return a list consisting of the atoms B, D, E, F, and G (in any order) in which no atom occurs more than once. 13. Define a recursive function SINGLETONS such that if e is any list of numbers and/or symbols then (SINGLETONS e) is a set that consists of all the atoms that occur just once in e. Examples: (SINGLETONSO)->NIL (SINGLETONS (GABCB)(G AC) (SINGLETONS '(H G A B C B))-> (H G A C) (SINGLETONS (A G A B C B))-> (G C) (SINGLETONS (B GABCB(GA C) Hint: When e is nonempty, consider the case in which (car e) is a member of (cdr e), and the case in which (car e) is not a member of (cdr e).] See the next page for instructions on how to submit your solutions. LISP Assignment 4: Page 4 of5 8. Without using MEMBER, complete the following definition of a recursive function POS such that if L is a list and E is an element ofL then (POS E L) returns the position of the first occurrence of E in L, and such that E is not an element ofL then (POS E L) returns 0 (DEFUN POS (E L) (COND ((ENDP L (EQUAL E (CAR L)) (T (LET (X (POSE (CDRL)))) (POS 5 "( 1 2 5 3 5 5 1 5))-> 3 (POS 'A "(3 2 1))-> 0 (POS(3B) '(3 B))-> 0 Examples: (POS (A B) ((K) (3 RC) A (A B) (KL L) (A B))-4 (POS (3 B)3 B)-1 9. Define a recursive function SPLIT-NUMS such that if N is a non-negative integer then (SPLIT-NUMS N) returns a list of two lists: The first of the two lists consists of the even integers between 0 and N in descending order, and the other list consists of the odd integers between 0 and N in descending order. Examples: (SPLIT-NUMS 0)((O) NIL) (SPLIT-NUMS7)-> ((6 4 2 0) (7 5 3 1)) (SPLIT-NUMS 8)-> ((8 6 4 2 0) (7 5 3 1)) IMPORTANT: In problems 10- 13 the term set is used to mean a proper list of numbers and/or symbols in which no atom occurs more than once You may use MEMBER but not the functions UNION, NUNION, REMOVE, DELETE, SET-DIFFERENCE, and SET-EXCLUSIVE-OR. 10. Define a recursive function SET-UNION such that if s1 and s2 are sets then (SET-UNION s1 s2) is a set that contains the elements of sl and the elements of s2, but no other elements. Thus (SET-UNION (A BCD) (C E F)) should return a list consisting of the atoms A, B, C, D, E, and F (in any order) in which no atom occurs more than once. 11. Define a recursive function SET-REMOVE such that if s is a set and x is an atom in s then (SET-REMOVE x s) is a set that consists of all the elements of s except x, but if s is a set and x is an atom which is not in s then (SET-REMOVE x s) returns a set that is equal to s. In problems 12 and 13 you may use the function SET-REMOVE from problem 11. 12. Define a recursive function SET-EXCL-UNION such that if sl and s2 are sets then (SET-EXCL-UNION s1 s2) is a set that contains all those atoms that are elements of exactly one of sl and s2, but no other atoms. (SET-EXCL-UNION sl s2) does not contain any atoms that are neither in sl nor in s2, and also does not contain the atoms that are in both of sl and s2. For example, (SET-EXCL-UNION'(ABCD) ECFG A)) should return a list consisting of the atoms B, D, E, F, and G (in any order) in which no atom occurs more than once. 13. Define a recursive function SINGLETONS such that if e is any list of numbers and/or symbols then (SINGLETONS e) is a set that consists of all the atoms that occur just once in e. Examples: (SINGLETONSO)->NIL (SINGLETONS (GABCB)(G AC) (SINGLETONS '(H G A B C B))-> (H G A C) (SINGLETONS (A G A B C B))-> (G C) (SINGLETONS (B GABCB(GA C) Hint: When e is nonempty, consider the case in which (car e) is a member of (cdr e), and the case in which (car e) is not a member of (cdr e).] See the next page for instructions on how to submit your solutions. LISP Assignment 4: Page 4 of5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!