Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))

Liste des GroupesRevenir à cl python 
Sujet : Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))
De : HenHanna (at) *nospam* devnull.tb (HenHanna)
Groupes : comp.lang.python comp.lang.scheme
Date : 10. Jun 2024, 03:36:39
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v45orn$3j3r$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 6/9/2024 7:05 PM, avi.e.gross@gmail.com wrote:
I remembered that HenHanna had been hard to deal with in the past and when
my reply to him/her/them bounced as a bad/fake address it came back to me
that I am better off not participating in this latest attempt to get us to
perform then probably shoot whatever we say down.
 A considerate person would ask questions more clearly and perhaps explain
what language they are showing us code from and so on.
 Life is too short to waste.
 -----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of HenHanna via Python-list
Sent: Sunday, June 9, 2024 5:20 PM
To: python-list@python.org
Subject: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))
 Chunk, ChunkC -- nice simple way(s) to write these in Python?
  (Chunk  '(a a   b    a a a   b b))
      ==> ((a a) (b)  (a a a) (b b))
  (Chunk  '(a a a a   b   c c   a a   d   e e e e))
      ==> ((a a a a) (b) (c c) (a a) (d) (e e e e))
  (Chunk  '(2 2   foo   bar bar   j j j   k   baz baz))
      ==> ((2 2) (foo) (bar bar) (j j j) (k) (baz baz))
 _________________
 (ChunkC  '(a a   b b b))
       ==> ((a 2)  (b 3))
 (ChunkC  '(a a   b      a a a   b b))
       ==> ((a 2)  (b 1)  (a 3)   (b 2))
i was just curiuos about simple, clever way to write it in Python
in Scheme (Gauche)
(use srfi-1)      ;; span
(define (gp x)
   (if (null? x) '()
     (let-values (((F L) (span (cut equal? (car x) <>) x)))
       (cons F (gp L)))))
(print (gp   '(a    b b    a a a   b b b b)))
(print (gp   '(c c c   a   d d d d   a   e e e e e)))
(define (gpC x)  (map (lambda (x) (list (car x) (length x))) (gp x)))
(print (gpC '(a    b b    a a a   b b b b)))
(print (gpC '(c c c   a   d d d d   a   e e e e e)))

Date Sujet#  Auteur
9 Jun 24 * in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))11HenHanna
10 Jun 24 +* Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))2MRAB
10 Jun 24 i`- Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))1HenHanna
10 Jun 24 +- Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))1<avi.e.gross
10 Jun 24 +* Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))4<avi.e.gross
10 Jun 24 i`* Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))3HenHanna
10 Jun 24 i +- Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))1<avi.e.gross
15 Jun 24 i `- Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))1B. Pym
10 Jun 24 +* Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))2Rob Cliffe
12 Jun 24 i`- Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))1HenHanna
11 Jun 24 `- Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))1<avi.e.gross

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal