Instructions
Objective
Write a program to implement basic functions using the LISP programming language.
Requirements and Specifications
Function intmax to return the greatest number among two integers.
Function dup which takes an element and returns a tuple with the element duplicated
.
Recursive function to add up all numbers from 1 to a given upper limit.
Function backwards to return the reverse order list of a given input list but no sublists
.
Function totalbackwards to return total reverse order list
.
Function with algorithm to detect palindrome.
Screenshots of output

Source Code
;;1
(defun intmax (x y)
(cond
((> x y) x)
(T y)))
(print (intmax 2 4))
(print (intmax -1 -2))
(print (intmax 0 0))
(print (intmax -2 2))
;;2
(defun dup (elem)
(cons elem (list elem)))
(print (dup 5))
(print (dup '(1 2 3)))
(print (dup 'a))
(print (dup nil))
;;3
(defun add-nums (x)
(cond
((<= x 1) 1)
(t (+ x (add-nums (- x 1))))))
(print (add-nums 1))
(print (add-nums 5))
(print (add-nums 10))
(print (add-nums -1))
;;4
(defun backwards (lst)
(cond
((null lst) lst)
(t (append (backwards (cdr lst)) (list (car lst))))))
(print (backwards '(a b c h i)))
(print (backwards nil))
(print (backwards '(a (b c) (h i))))
(print (backwards '(a)))
;;5
(defun totalbackwards (lst)
(cond
((null lst)
lst)
((listp (car lst))
(append (totalbackwards (cdr lst)) (list (totalbackwards (car lst)))))
(t
(append (totalbackwards (cdr lst)) (list (car lst))))))
(print (totalbackwards '(a (b c) ((l k (t)) h i))))
(print (totalbackwards nil))
(print (totalbackwards '((a b) ((c d) e))))
(print (totalbackwards '(a b () c d)))
;;6
(defun palindrome (lst)
(equal lst (backwards lst)))
(print (palindrome '(r o t o r)))
(print (palindrome '(r a c e c a r)))
(print (palindrome '(p a l i n d r o m e)))
(print (palindrome '(r a c e c a r s)))