Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a recursive function FIRSTLAST that takes a list as a parameter. It will return a list made up of the first and last item
Create a recursive function FIRSTLAST that takes a list as a parameter. It will return a list made up of the first and last item in the original list. Do error checking on the input (e.g. checking that it is a list of at least two items).
[26]> (firstlast '(a b c)) (a c) [28]> (firstlast "foo") Error in FIRSTLAST function. Parameter must be a list, but was "foo". NIL [30]> (firstlast '(((a) b c) 1 2 (3 5) 7 9)) ((a) b c) 9)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started