Sujet : Re: which articles are sold?
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lispDate : 23. Jun 2025, 09:53:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103b4m0$159p4$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Lieven Marchand wrote:
if we have this list:
(a <sold> b c d <sold> e f g <sold>)
that shows that article a, d and g are sold and the rest are not how
can we put all the sold articles in one list:
(a d g)
More homework?
(loop for (first next) on '(a <sold> b c d <sold> e f g <sold>)
when (eql next '<sold>)
collect first)
Scheme:
(define items '(a <sold> b c d <sold> e f g <sold> h i <sold>))
(filter-map
(lambda(x y) (and (eq? '<sold> y) x))
items
(cdr items))
===>
(a d g i)