Delete occurences of item from non-linear list
|Added at||2017-01-02 16:01|
I am trying to delete all occurrences of an element from a list, from any levels of the list. I am required to use a map function though. I am using Common Lisp. For example I'd want to be able to do:
What I've tried so far: This function will do what's needed, sort of. It will replace all occurences of the given element with NIL, so it's not exactly what I want.
This will do
My second try is with the mapcap function, since this one won't return a list the same size as the input list. This will do what's needed, but it will 'destroy' my initial list, as in, it will bring all sublists 'to surface'.
So this indeed does
I'd want it to do
I hope my question is well formed and detailed enough, and I am providing working examples. Can someone give me a few hints on how to solve this problem?