Re: tasters wanted

Liste des GroupesRevenir à cl lisp 
Sujet : Re: tasters wanted
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.lisp
Date : 19. Jul 2024, 19:09:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240719100337.314@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
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

Date Sujet#  Auteur
18 Jul 24 * Re: tasters wanted9B. Pym
18 Jul 24 +* Re: tasters wanted7B. Pym
15 Aug 24 i`* Re: tasters wanted6B. Pym
15 Aug 24 i `* Re: tasters wanted5B. Pym
15 Aug 24 i  +* Re: tasters wanted2B. Pym
15 Aug 24 i  i`- Re: tasters wanted1Kaz Kylheku
17 Aug 24 i  `* Re: tasters wanted2B. Pym
18 Aug 24 i   `- Re: tasters wanted1Jeff Barnett
19 Jul 24 `- Re: tasters wanted1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal