#(1 1 1 2 2 2 3 3 3 4 4 4) . 3 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4))

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

#(1 1 1 2 2 2 3 3 3 4 4 4) . 3 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4))

Stéphane Ducasse
Hi guys 

do you know if we have around a method doing the following?

#(1 1 1 2 2 2 3 3 3 4 4 4) . 3 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4)) 

it could also be another one

#(1 1 1 2 2 2 3 3 3 4 4 4) . 4 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4)) 

S

--------------------------------------------
Stéphane Ducasse
03 59 35 87 52
Assistant: Aurore Dalle 
FAX 03 59 57 78 50
TEL 03 59 35 86 16
S. Ducasse - Inria
40, avenue Halley, 
Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
Villeneuve d'Ascq 59650
France

Reply | Threaded
Open this post in threaded view
|

Re: #(1 1 1 2 2 2 3 3 3 4 4 4) . 3 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4))

Pharo Smalltalk Developers mailing list
I don't understand your intent.

Do they group together because they have the same value or do they just get grouped into subgroups of size three or do they get grouped as runs?

This works:

#(1 1 1 2 2 2 3 3 3 4 4 4) groupByRuns:  [ :ea | ea ] -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4)) 

On Jun 3, 2020, at 1:53 PM, Stéphane Ducasse <[hidden email]> wrote:

Hi guys 

do you know if we have around a method doing the following?

#(1 1 1 2 2 2 3 3 3 4 4 4) . 3 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4)) 

it could also be another one

#(1 1 1 2 2 2 3 3 3 4 4 4) . 4 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4)) 

S

--------------------------------------------
Stéphane Ducasse
03 59 35 87 52
Assistant: Aurore Dalle 
FAX 03 59 57 78 50
TEL 03 59 35 86 16
S. Ducasse - Inria
40, avenue Halley, 
Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
Villeneuve d'Ascq 59650
France


Reply | Threaded
Open this post in threaded view
|

Re: #(1 1 1 2 2 2 3 3 3 4 4 4) . 3 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4))

Torsten Bergmann
In reply to this post by Stéphane Ducasse

Hi Stef,
 
from the (incomplete) sample it is unclear what is really needed:
 
 1. Both return the same result: #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4))  which is syntactically equal to #(#(1 1 1) #(2 2 2) #(3 3 3) #(4 4 4))

    So why did you leave out the # for the contained sub-array with 2's and 3's?

 2. When the result is equal in both examples why give a different argument like 3 and 4? 

 3. What about edge case inputs like:   #(1 1 1 2 2 2 4 4 4)          not having sucessors/predecessor order
                                        #(2 2 2 1 1 1 3 3 3 4 4 4)    with different order (not ascending)
                                        #(1 1 1 1 2 2 2 3 3 3 4 4 4)  where 1 is included more often than the other   

 4. ...


Nonetheless: the closest that might possibly be of use is #groupByRuns: message


    #(1 1 1 2 2 2 3 3 3 4 4 4) groupByRuns: [:e | e ]    ->  #(#(1 1 1) #(2 2 2) #(3 3 3) #(4 4 4))

Have fun
T.
  

Gesendet: Mittwoch, 03. Juni 2020 um 22:53 Uhr
Von: "Stéphane Ducasse" <[hidden email]>
An: "Pharo Development List" <[hidden email]>
Betreff: [Pharo-dev] #(1 1 1 2 2 2 3 3 3 4 4 4) . 3 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4))

Hi guys 
 
do you know if we have around a method doing the following?
 
#(1 1 1 2 2 2 3 3 3 4 4 4) . 3 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4)) 
 
it could also be another one
 
#(1 1 1 2 2 2 3 3 3 4 4 4) . 4 -> #(#(1 1 1) (2 2 2) (3 3 3) #(4 4 4)) 
 
S
 

--------------------------------------------
Stéphane Ducasse
http://stephane.ducasse.free.fr / http://www.pharo.org[http://www.pharo.org
03 59 35 87 52
Assistant: Aurore Dalle 
FAX 03 59 57 78 50
TEL 03 59 35 86 16
S. Ducasse - Inria
40, avenue Halley, 
Parc Scientifique de la Haute Borne, Bât.A, Park Plaza

Villeneuve d'Ascq 59650
France