Hi. Firstly, many of us here prefer full sentences and typo-checked writing. Secondly, some might feel that you're asking us do do your homework. I guess the latter isn't so, because it is only help you are asking.
If you already have the non-recursive part, maybe you should post it so we can comment on it.
As for the non-recursive part, you will need a list to play stack. This stack is usually handled by common lisp itself, but you will have to make it yourself if you want it non-recursively. Every time you go down a list, your stack gets an extra layer. Note that lisp does not create a stack every time the function itself is called from a function, sometimes it can do optimization, like tail recursion
. Basically we do tail recursion manually when we write the (partially recursive, partially iterative) function:
- Code: Select all
(defun deep-map (fun list)
(loop for el in list collect (if (listp el) (deep-map fun el) (funcall fun el)))
In order to do this iteratively you will have to do the stack stuff whenever is deep-map is called inside the loop there. (You could do the loop with do, dolist too, of course.)