#1182 Add #pairsDo:

Closed
opened 8 years ago by nero · 0 comments

Originally at 2015-05-21T10:54:09Z by Hannes Hirzel

Pharo has #pairsDo:

pairsDo: aBlock 
    "Evaluate aBlock with my elements taken two at a time. 
     If there's an odd number of items, ignore the last one.  
     Allows use of a flattened array for things that naturally group into pairs.  
     See also pairsCollect:"

1 to: self size // 2 do:
    [:index | aBlock value: (self at: 2 * index - 1) value: (self at: 2 * index)]

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Originally at 2015-05-21T10:54:09Z by Hannes Hirzel Pharo has #pairsDo: pairsDo: aBlock "Evaluate aBlock with my elements taken two at a time. If there's an odd number of items, ignore the last one. Allows use of a flattened array for things that naturally group into pairs. See also pairsCollect:" 1 to: self size // 2 do: [:index | aBlock value: (self at: 2 * index - 1) value: (self at: 2 * index)] <bountysource-plugin> --- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/16432306-add-pairsdo?utm_campaign=plugin&utm_content=tracker%2F79201&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F79201&utm_medium=issues&utm_source=github). </bountysource-plugin>
Sign in to join this conversation.
No Label
No Milestone
No assignee
1 Participants
Loading...
Cancel
Save
There is no content yet.