[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: help me with starting this in files

William James

8/26/2015 11:18:00 PM

Pascal Bourguignon wrote:

> ;; 4.(15) Write a function rall that take an element (note that the
> ;; element could be a list as well) and a list as parameters and removes
> ;; all occurrences of the element (not just the top-level element).
>
> (defun rall (e l)
> (loop with p = l
> for n = (remove e p)
> until (equal p n)
> do (setf p n)
> finally (return (mapcar (lambda (sl)(if (listp sl) (rall e sl) sl)) n))))

Gauche Scheme:

(define (rall e l)
(map
(lambda (sl) (if (pair? sl) (rall e sl) sl))
(delete e l)))

gosh> (rall 2 '(0 2 5 2 (2 6 (8 9 2)) 7))
(0 5 (6 (8 9)) 7)

--
The report card by the American Society of Civil Engineers showed the national
infrastructure a single grade above failure, a step from declining to the point
where everyday things simply stop working the way people expect them to. ---
washingtonpost.com/local/trafficandcommuting/us-infrastructure-gets-d-in-annual-report/2013/03/19/c48cb010-900b-11e2-9cfd-36d6c9b5d7ad_story.html