Sujet : Re: tasters wanted
De : jbb (at) *nospam* notatt.com (Jeff Barnett)
Groupes : comp.lang.lispDate : 18. Aug 2024, 07:19:28
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v9s092$2996i$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
On 8/17/2024 12:24 PM, B. Pym wrote:
B. Pym wrote:
<SNIP SNIP>
>
(define (collect-repeats sorted)
(let (accum '() tmp '() a)
(until (empty? sorted)
(setq a (sorted 0))
(setq tmp
(collect
(and (true? sorted) (= a (sorted 0)) (pop sorted))))
(when (> (length tmp) 1) (push tmp accum)))
(reverse accum)))
Shorter:
(define (collect-repeats sorted)
(local (accum tmp a)
(while sorted
(setq a (sorted 0))
(setq tmp
(collect (and (true? sorted) (= a (sorted 0)) (pop sorted))))
(and (1 tmp) (push tmp accum)))
(reverse accum)))
Shorter!!!!!!! Shorter because you moved the and clause embedded in the collect clause into the same line as the collect operator. Good work.
I take from your recent barrage of similarly helpful postings that you are once again between employers. It's probably good to keep in shape doing all these coding exercises.
-- Jeff Barnett