Get the first and last atom of the list and add them
2 answers
You need to create your list from two ends. I would suggest the following:
- Create two lists from the existing one
- Put two new lists together, when the input list is empty, flip the second list before merging them.
So, you should expect the function call to look like this:
(myFunc inputList forwardList willBeBackwardList)
and when inputList
empty you want to do something like
(append forwardList (reverse willBeBackwardList))
(the exact names of the built-in functions depend on the lisp used).
0
source to share