Question: subject: Principle of programing please answer me correctly i need 1,2 , 3,4 and 5 please On euclid and venus, when you LOAD a function
subject: Principle of programing
please answer me correctly
i need 1,2 , 3,4 and 5 please
On euclid and venus, when you LOAD a function definition for any of problems 1 7, your function will replace the predefined function that has the same name. So if, for example, your definition of SUM for problem 1 is wrong then, after you LOAD your definition of SUM, your definition of MY-SUM for problem A (which calls SUM) may stop working until you restart Clisp, even if it is correct. Note: You may use ENDP or NULL to test whether a list is empty. Recall that (ENDP L) = (NULL L) if the argument is a list. An evaluation error occurs if ENDP is called with an argument that is not a list.
1. Define a recursive function SUM with the properties stated in problem A. Note that whereas NIL is not a valid argument of MY-SUM, NIL is a valid argument of SUM.
2. Define a recursive function NEG-NUMS with the properties stated in problem B. Note that NIL is a valid argument of NEG-NUMS.
3. Define a recursive function INC-LIST-2 with the properties stated in problem C. Note that the first argument of INC-LIST-2 may be NIL.
4. Define a recursive function INSERT with the properties stated in problem D. Note that the second argument of INSERT may be NIL.
5. Define a recursive function ISORT with the properties stated in problem E. Hint: In your definition of ISORT you should not have to call any function other than ISORT itself, INSERT, CAR, CDR, and ENDP. (A special form such as IF or COND is not considered to be a function, and will be needed.) LISP Assignment 4: Page 4 of 5 6. Define a recursive function SPLIT-LIST with the properties stated in problem F. 7. Define a recursive function PARTITION with the properties stated in problem G. 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 of L then (POS E L) returns the position of the first occurrence of E in L, and such that if E is not an element of L then (POS E L) returns 0. (DEFUN POS (E L) (COND ((ENDP L) ... ) ((EQUAL E (CAR L)) ... ) (T (LET ((X (POS E (CDR L)))) ... )))) Examples: (POS 5 '(1 2 5 3 5 5 1 5)) => 3 (POS 'A '(3 2 1)) => 0 (POS '(3 B) '(3 B)) => 0 (POS '(A B) '((K) (3 R C) A (A B) (K L 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) => ((0) NIL) (SPLIT-NUMS 7) => ((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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
