Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeff Barnett Newsgroups: comp.lang.lisp Subject: Re: tasters wanted Date: Sat, 17 Aug 2024 23:19:28 -0600 Organization: A noiseless patient Spider Lines: 35 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 18 Aug 2024 07:19:30 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e83f565442c57ba8a0f2e764ec9a33b0"; logging-data="2401490"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jcroIEAtuxv9il/XPoGcA9NW/BuwvBXI=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:8wz4UopuSHkptzpx8VWa8V+DY3U= X-Antivirus-Status: Clean In-Reply-To: Content-Language: en-US X-Antivirus: AVG (VPS 240817-12, 8/17/2024), Outbound message Bytes: 2243 On 8/17/2024 12:24 PM, B. Pym wrote: > B. Pym wrote: >> >> (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