Deutsch   English   Français   Italiano  
<20240719100337.314@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!feeds.phibee-telecom.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.lang.lisp
Subject: Re: tasters wanted
Date: Fri, 19 Jul 2024 17:09:21 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <20240719100337.314@kylheku.com>
References: <v7bkuk$2hcim$1@dont-email.me>
Injection-Date: Fri, 19 Jul 2024 19:09:21 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="329fa895c5d6908477a80b789f62a073";
	logging-data="3237795"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/Whw7vXr4gbdiGUsWEClU9ATYVvzgiZR0="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:HIenfFM7WqlVzxVsGhevf831VYk=
Bytes: 2427

On 2024-07-18, B. Pym <Nobody447095@here-nor-there.org> wrote:
> Gauche Scheme
>
> (use gauche.collection) ;; fold2
>
> (define (monotonic the-list :key (test equal?))
>   (receive (tmp result)
>     (fold2
>       (^(x tmp result)
>         (if (or (null? tmp) (test x (car tmp)))
>           (values (cons x tmp) result)
>           (values (list x) (cons tmp result))))
>       '() '()
>       the-list)
>     (reverse (map reverse
>       (if (pair? tmp) (cons tmp result) result)))))
>
> (monotonic '(0 2 3 4 0 5 7 9 6) :test >)
>  ===>
> ((0 2 3 4) (0 5 7 9) (6))
>
> (define (collect-repeats sorted-list :key (test equal?))
>   (remove (^x (null? (cdr x)))
>     (monotonic sorted-list :test test)))
>
> (collect-repeats '(2 2 3 4 5 5 7 8 8))
>  ===>
> ((2 2) (5 5) (8 8))
>
> (collect-repeats '(2 2 3 4 5 5 7 8 8 9))
>  ===>
> ((2 2) (5 5) (8 8))

This is the TXR Lisp interactive listener of TXR 294.
Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
If you get your macros hot enough, you get syntactic caramel!
1> [partition-by identity '(2 2 3 4 5 5 7 8 8 9)]
((2 2) (3) (4) (5 5) (7) (8 8) (9))
2> (remove-if (opip len (eq 1))
              [partition-by identity '(2 2 3 4 5 5 7 8 8 9)])
((2 2) (5 5) (8 8))
3> (keep-if [chain len pred plusp]
            [partition-by identity '(2 2 3 4 5 5 7 8 8 9)])
((2 2) (5 5) (8 8))

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca