Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Investing All In One

Authors: Eric Tyson

1st Edition

1119376629, 978-1119376620

Students also viewed these Databases questions

Question

Which of these seems to be a good idea?

Answered: 1 week ago