[squeak-dev] The Inbox: Collections-mt.941.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Apr 14 12:51:12 UTC 2021


A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-mt.941.mcz

==================== Summary ====================

Name: Collections-mt.941
Author: mt
Time: 14 April 2021, 2:51:04.673628 pm
UUID: 93df256c-2d6c-e246-87aa-4296ff9c993d
Ancestors: Collections-ul.940

(Not a) proposal. In #do:separatedBy: optionally provide the elements around that separation to the block. Looks like an interleaved combination of #do: and #overlappingPairsDo:.

Here is a (not convincing) example:

(1 to: 20)
	do: [:num | Transcript showln: num]
	separatedBy: [:a :b | Transcript showln: a+b]
	
Maybe this is something. Haven't found a good example yet.

=============== Diff against Collections-ul.940 ===============

Item was changed:
  ----- Method: Collection>>do:separatedBy: (in category 'enumerating') -----
  do: elementBlock separatedBy: separatorBlock
  	"Evaluate the elementBlock for all elements in the receiver,
  	and evaluate the separatorBlock between."
  
+ 	| beforeFirst lastSeen | 
- 	| beforeFirst | 
  	beforeFirst := true.
  	self do:
  		[:each |
  		beforeFirst
  			ifTrue: [beforeFirst := false]
+ 			ifFalse: [separatorBlock cull: lastSeen cull: each].
+ 		elementBlock value: each.
+ 		lastSeen := each]!
- 			ifFalse: [separatorBlock value].
- 		elementBlock value: each]!

Item was changed:
  ----- Method: SequenceableCollection>>do:separatedBy: (in category 'enumerating') -----
  do: elementBlock separatedBy: separatorBlock
  	"Evaluate the elementBlock for all elements in the receiver,
  	and evaluate the separatorBlock between."
  
+ 	| lastSeen |
  	1 to: self size do:
  		[:index |
+ 		index = 1 ifFalse: [separatorBlock cull: lastSeen cull: (self at: index)].
+ 		lastSeen := self at: index.
+ 		elementBlock value: lastSeen]!
- 		index = 1 ifFalse: [separatorBlock value].
- 		elementBlock value: (self at: index)]!



More information about the Squeak-dev mailing list