Answered step by step
Verified Expert Solution
Question
1 Approved Answer
11. deep-reverse (OPTIONAL BONUS) Define a function similar to the built-in reverse function, except that it acts recursively, reversing the order the members of any
11. deep-reverse (OPTIONAL BONUS) Define a function similar to the built-in reverse function, except that it acts recursively, reversing the order the members of any nested sublists. You may not use the built-in reverse function as a helper function. However, you may use your own my-reverse function as a helper function Input: A single list which may contain an arbitrary number of elements and sublists, each sublists may also contain an arbitrary number of elements and sublists, nested to an any depth Output: A new list which contains all elements in reverse order, as well as recursively reverse order all members of sublists Example: (deep-reverse (((4 3) 6) ((7 2 9)(5 1))) (((1 5) (9 2 7)) (6 (3 4))) > (deep-reverse'((1 2) 3) (3 (2 1)) (deep-reverse ((4 5))) ((5 4) > (deep-reverse '(3 6 9 12) (12 9 6 3)
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