Iterating through two collections in parallel

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

Iterating through two collections in parallel

Prof. Andrew P. Black
What method will execute a two-parameter block with corresponding pairs of elements from two separate Ordered Collections.

something like  this example:

                        #(1 2 3) and: 'abc' do:  [ :aNumber :aLetter |  do something first with 1 and $a,
                                                                                                 then with 2 and $b,
                                                                                                 and finally with 3 and $c ]

I searched for ‘corresponding’  and ‘pairs’ and failed to find what I’m looking for.  I tried ‘zip’.  It’s hard to search for this with an example.  

        Andrew





Reply | Threaded
Open this post in threaded view
|

Re: Iterating through two collections in parallel

Denis Kudriashov
Hi
Try this one:
                        #(1 2 3) with: 'abc' do:  [ :aNumber :aLetter |  do something first with 1 and $a,
                                                                                                 then with 2 and $b,
                                                                                                 and finally with 3 and $c ]

2017-11-14 10:10 GMT+01:00 Prof. Andrew P. Black <[hidden email]>:
What method will execute a two-parameter block with corresponding pairs of elements from two separate Ordered Collections.

something like  this example:

                        #(1 2 3) and: 'abc' do:  [ :aNumber :aLetter |  do something first with 1 and $a,
                                                                                                 then with 2 and $b,
                                                                                                 and finally with 3 and $c ]

I searched for ‘corresponding’  and ‘pairs’ and failed to find what I’m looking for.  I tried ‘zip’.  It’s hard to search for this with an example.

        Andrew