Question: Haskell Programming (Not any other Language): Simply answer the question (Code) 4.[15 points] Define a function swap _ends that takes a list and returns the
Haskell Programming (Not any other Language): Simply answer the question (Code)

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 [ ]- [ ] 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
