What is the function to a list in Scheme? It needs to be able to handle nested lists.
So that if you do something like (reverse '(a (b c d) e))
you'll get (e (b c d) a)
as the output.
How should I approach this problem? I'm not just looking for an answer, but something that will help me learn.
Explanation:
Rules:
1. If list is empty, then reverse list is also empty
2. else behind reverse tail of the list add first element of the list
Look at at this code this way:
reverse1 is name of the function, l is parameter
if list is empty then reverse is also empty else call reverse1 function with (cdr l) which is tail of list and append that to first alement (car l) that you make as a list
in your example (pseudo cod):