Page 1 of 1

top level delete?

Posted: Wed Apr 15, 2009 3:26 am
by Arkhan
What would be meant by deleting all occurrences of an element from a list at the top-level?

an example:

(del '(a b c) '(a (b c) (a b c) (d (a b c) e) (a c) (a b c) (r (a b c)))

Would any of the (a b c) occurrences be deleted?

I am not sure what top-level means.

Re: top level delete?

Posted: Thu Apr 16, 2009 11:19 am
by Jasper
Probably what is meant is the ones caught when you #'eql them iterating the first list, and not the lists within. So the result for your example would be just the first a removed of the second argument. (Assuming the first list is the ones that have to be deleted and the second the list to delete from)

You can write it using #'delete-if, with predicate being whether it is in list of things you want to delete. Or you can use #'loop/#'iter and collect those you do not want deleted.

Re: top level delete?

Posted: Thu Apr 16, 2009 3:45 pm
by methusala
AFAIK 'top level' refers to the REPL, the read eval print loop. This is the command prompt you see for the lisp image. So doing something at the 'top-level' means doing it at the lisp command prompt. This sounds like an exercise to practice using car and cdr interactively.