Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!