202205261415 Arithmetic in Lisp

Given two operands a and b which are real numbers, define the operators,

a+b, a-b, a\times b, a\div b, a^{b}, \sqrt[b]{a}, a\bmod b,

with respect to arithmetic operations such as addition, subtraction, multiplication, division, exponentiation, rooting, and Modulo.

Not so accustomed to these, Lisp cannot interpret or compile them until we have defined those seven primitive functions, better known as symbolic computations; as were newborn infants taught human intelligence by grownup adults between homo sapiens.

To Lisp, arithmetic operations are usually \textrm{\scriptsize{NOT}} predefined. We have in our toolkit \textrm{\scriptsize{ONLY}} three mathematical functors, i.e., list, iteration, and recursion.

The roots of quadratic equation are given by the formula:

\displaystyle{x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}}

the expected outcome of which is calculated by parts, first the discriminant ‘delta’:

\Delta = b^2-4ac;

then the plus-minus ‘pm’:

\pm (x)=(+x,-x);

and hence

will solve for real roots, ignoring the complex though.

\therefore Predefining the seven primitive functions is in order for solving any computational problems by Lisp.

(to be continued)

202111251402 Exercise 2.59 in Lisp

Implement the union-set operation for the unordered-list representation of sets.

Extracted from Structure and Interpretation of Computer Programs, SICP


Attempts.

Define a function element-of-set?by

to determine whether an object xis an element of a set set.

Define a function intersection-set by

to draw the intersection intersection-set of two sets set1 and set2.

Define a function union-set by

to draw the union  union-set of two sets set1 and set2.