Question: 4.[15 points] Define a function swap ends that takes a list and returns the same list but with the first and last elements swapped. E.g.,
![4.[15 points] Define a function swap ends that takes a list](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2fa841b4e4_87566f2fa83b1d9d.jpg)
4.[15 points] Define a function swap ends that takes a list and returns the same list but with the first and last elements swapped. E.g., swap_ends "hello"- "oellh" (remember, strings are lists of characters). Use function definition by cases to ensure that swap_ends [ ]-[1 and swap_ends [x]-[x]. (I.e., return empty and singleton lists as is)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
