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 : <avi.e.gross (at) *nospam* gmail.com>
Groupes : comp.lang.python
Date : 10. Jun 2024, 01:30:02
Autres entêtes
Message-ID : <mailman.106.1717975807.2909.python-list@python.org>
References : 1 2
User-Agent : Microsoft Outlook 16.0
HH,

Before bothering, it might be helpful if you spelled out a bit more in the
way of requirements that would satisfy you and perhaps show your attempts.

Your examples suggest it would be fairly simple to create an iterator, for
example, that would yield as it examined one item at a time until it ran out
or the next item was not the same. It could then either return a tuple it
had collected so far since the last yield, or for what you call chunkC,
return a tuple containing one copy of the item and a count of how many.

But if you want something else, such as a list all at once, that too would
be trivial, perhaps leveraging the above.

-----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))
--
https://mail.python.org/mailman/listinfo/python-list


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