Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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.

image text in transcribed

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 bb a)) (palindromep '(a b c b a)) (palindromep'(a b c)) nil (palindromep'(a (de) b (de) a)) (palindromep '(a (de) 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. No iteration, everything should be done with functions and list manipulators 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 bb a)) (palindromep '(a b c b a)) (palindromep'(a b c)) nil (palindromep'(a (de) b (de) a)) (palindromep '(a (de) 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. No iteration, everything should be done with functions and list manipulators

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions