top level delete?

Discussion of Common Lisp

top level delete?

Postby Arkhan » Wed Apr 15, 2009 3:26 am

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?

Postby Jasper » Thu Apr 16, 2009 11:19 am

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.
Posts: 209
Joined: Fri Oct 10, 2008 8:22 am
Location: Eindhoven, The Netherlands

Re: top level delete?

Postby methusala » Thu Apr 16, 2009 3:45 pm

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.
Posts: 35
Joined: Fri Oct 03, 2008 6:35 pm

Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 8 guests