[Pkg] The Trunk: Collections-nice.502.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Mar 6 22:05:00 UTC 2013


Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.502.mcz

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

Name: Collections-nice.502
Author: nice
Time: 24 February 2013, 7:30:26.441 pm
UUID: 493d78e4-ccce-434c-98ae-90f22102cdce
Ancestors: Collections-fbs.501

Let String combinations produce Strings rather than Array of Characters.
This is not perfect for WideString which are not necessarily simplified to ByteString, but IMO better than Array.

=============== Diff against Collections-fbs.501 ===============

Item was changed:
  ----- Method: SequenceableCollection>>combinations:atATimeDo: (in category 'enumerating') -----
  combinations: kk atATimeDo: aBlock
  	"Take the items in the receiver, kk at a time, and evaluate the block for each combination.  Hand in an array of elements of self as the block argument.  Each combination only occurs once, and order of the elements does not matter.  There are (self size take: kk) combinations."
+ 	" (1 to: 5) combinations: 3 atATimeDo: [:each | Transcript cr; show: each printString]"
- 	" 'abcde' combinations: 3 atATimeDo: [:each | Transcript cr; show: each printString]"
  
  	| aCollection |
  	aCollection := Array new: kk.
  	self combinationsAt: 1 in: aCollection after: 0 do: aBlock!

Item was added:
+ ----- Method: String>>combinations:atATimeDo: (in category 'enumerating') -----
+ combinations: kk atATimeDo: aBlock
+ 	"Gather the combinations into a String rather than an Array"
+ 	
+ 	" 'abcde' combinations: 3 atATimeDo: [:each | Transcript cr; show: each printString]"
+ 
+ 	| aCollection |
+ 	aCollection := String new: kk.
+ 	self combinationsAt: 1 in: aCollection after: 0 do: aBlock!



More information about the Packages mailing list