Question: 1. Write a lisp function that averages its three arguments, first checking to see that they are numbers; if they are not, have the function

1. Write a lisp function that averages its three arguments, first checking to see that they are numbers; if they are not, have the function AVERAGE return 'error.

2. Write a lisp function QUADRATIC of three arguments A, B, and C which returns the roots of the quadratic equation A z^2 - B z - C = 0 as a list. For example, (QUADRATIC 1 -2 3) would return (-3 1).

3. Modify the function QUADRATIC to the function QUADRATICL so that the new function returns the largest root.

4. The Euclidean norm of a vector (x1, x2 , x3, ..., xn) of length n is defined as sqrt((x1)^2 + (x2)^2 + ... + (xn)^2)). Suppose we represent a vector (x1, x2 , x3, ..., xn) as an n-element list (x1 x2 x3 ... xn). Write a function EUCLIDEAN_NORM that returns the norm of its input argument vector. Assume that the maximum length of the vector is 25.

5. If you are distressed that the names CAR and CDR are non-mnemonic, you are now in a position to do something about it. Define functions MYFIRST and MYREST that behave exactly like CAR and CDR, respectively.

6. Write a recursive lisp function COUNT-ATOMS that counts the number of non-nil atoms that appear at all levels of a list. For example, (COUNT-ATOMS '(a (b ((c))) (d (e) f))) returns 6.

7. Write a recursive function REPLACE_ALL that replaces all occurrences of an element from a list. For example, (REPLACE_ALL '(a x) '(a b (a) c (a d) e)) returns (x b (x) c (x d) e).

8. Write a lisp predicate NON-MEMBER that returns true if the value of its first argument does NOT occur in the value of its second. For example, (NON-MEMBER 'a '(b a c a)) should return false, while (NON-MEMBER 'a '(b c d)) should return true.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To address each part of your question Ill provide stepbystep solutions for implementing the requested Lisp functions Function AVERAGE To create a func... View full answer

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!