Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: "B. Pym" Newsgroups: comp.lang.lisp,comp.lang.scheme Subject: Re: Learning Lisp in Linux? Date: Sun, 22 Jun 2025 20:44:57 -0000 (UTC) Organization: A noiseless patient Spider Lines: 55 Message-ID: <1039q08$o8dh$1@dont-email.me> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Injection-Date: Sun, 22 Jun 2025 22:44:58 +0200 (CEST) Injection-Info: dont-email.me; posting-host="f333d4e956116c873f4f35d019e51465"; logging-data="795057"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1853NjwSlPgu5b4cJBVGxMl" User-Agent: XanaNews/1.18.1.6 Cancel-Lock: sha1:cRHacBUHiwj4kAafqKR/F+TvBZ0= B. Pym wrote: > Pascal Costanza wrote: > > > > I'm not advocating tail-recursion instead of specialized iteration > > > mechanisms closer to the problem domain. I'm just saying tail- > > > recursion code isn't anywhere as low-level as you're making it up to > > > be. > > > > It actually is, and your posting below shows it very nicely. > > > > >> Here is a nice example using loop: > > > > > > >> (loop for (key value) on property-list by #'cddr > > >> unless (member key excluded-keys) > > >> append (list key value)) ; [1] > > > > As a function: > > > > (defun filter (excluded-keys property-list) > > (loop for (key value) on property-list by #'cddr > > unless (member key excluded-keys) > > nconc (list key value))) > > > > > (filter '(c d) '(a 1 b 2 b 3 c 4 d 5 c 6)) > > (A 1 B 2 B 3) > > > > The result is a correct property list > > Gauche Scheme > > (define (remove-props bad-keys prop-list) > (concatenate > (remove (^p (member (car p) bad-keys)) > (slices prop-list 2)))) > > (remove-props '(c d) '(a 1 b 2 b 3 c 4 d 5 c 6)) > ===> > (a 1 b 2 b 3) Using "is": (define (remove-props bad-keys prop-list) (concatenate (remove (is car member bad-keys) (slices prop-list 2)))) Given: (define is (case-lambda [(x) (lambda(y) (equal? y x))] [(pred x) (lambda(y) (pred y x))] [(key pred x) (lambda(y) (pred (key y) x))]))