Assignment: #lisp2 Due: 12/01/2017 Points: 6
Specification

Write a Lisp program that defines and evaluates the following three functions.

;; evaluates four parameters using the arithmetic expression
;;     (a + m * (m - 1) - s) / d
;; returns nil if divide-by-0

(defun arithmetic (a m s d) 
   ; your code (which might be multiple lines) goes here...


;; similar to the #carcdr C++ programming assignment
;; this function must be implemented using recursion
;; see PART1 in the output section 

(defun carcdr (alist) 
   ; your code (which might be multiple lines) goes here...


;; receives a list as a parameter and prints to the standard
;; output stream the following:
;;
;; list  __the_list_parameter__ has W elements
;; ...X of the Y atom elements are even numbers
;; ...Z of the elements are lists
;;
;; this function must use the (and) and (atom) functions

(defun use-and-and-atom (alist)
   ; your code (which might be multiple lines) goes here...
The Main Part of the Program

The following code should be used as the main part of your program.

(format t "***PART 0 (arithmetic)***~%");
(format t "~d ~d ~d~%" (arithmetic 2 4 5 3) 
                       (arithmetic 3 1 3 8)
                       (arithmetic 2 5 6 0)) 

(format t "~%***PART 1 (carcdr)***~%");
(carcdr '(5 8 13 21 34))

(format t "~%***PART 2 (use-and-and-atom)***~%");
(use-and-and-atom '(5 (3 6) 8 (1 1 1) 9 4 (21) 8))
(use-and-and-atom '((red green blue) stop 5 2 (no go) 7))
Program Output

The output of your program should match the following.

***PART 0 (arithmetic)***
3 0 NIL

***PART 1 (carcdr)***
(car '(5 8 13 21 34)) = 5
(cdr '(5 8 13 21 34)) = (8 13 21 34)
(car '(8 13 21 34)) = 8
(cdr '(8 13 21 34)) = (13 21 34)
(car '(13 21 34)) = 13
(cdr '(13 21 34)) = (21 34)
(car '(21 34)) = 21
(cdr '(21 34)) = (34)
(car '(34)) = 34
(cdr '(34)) = NIL

***PART 2 (use-and-and-atom)***
list  (5 (3 6) 8 (1 1 1) 9 4 (21) 8)  has 8 elements
...3 of the 5 atom elements are even numbers
...3 of the elements are lists
list  ((RED GREEN BLUE) STOP 5 2 (NO GO) 7)  has 6 elements
...1 of the 4 atom elements are even numbers
...2 of the elements are lists