Starting from:
$30

$24

List Homework - Palindrome

Save your files with a .lisp extension and then to run the files use clisp like this

[Csci305]$clisp mylispfile.lisp

Write a Common Lisp function called palindromep that takes a list as input and returns 't' is the list is a palindrome, and 'nil' otherwise. Examples of the function in operation are shown below (user input is in red):

(palindromep '(a b b a))
t
(palindromep '(a b c b a))

t
(palindromep '(a b c))

nil
(palindromep '(a (d e) b (d e) a))
t

(palindromep '(a (d e) b (e d) a))

nil

Note in the 4th and 5th examples above that we do not look into sublists, meaning that matching sublists in both sides of the palindrome must be identical rather than the reverse of each other.

Requirements:

    • You must implement your function using recursion, not iteration.
    • No built in functions except first, last, list, atom, you can use reverse to help get the last element in the list only. You can also use = to test for equality, or not if needed.
    • No iteration, everything should be done with functions and list manipulators.

More products