[squeak-dev] The Trunk: Collections-mt.591.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Jan 14 12:13:23 UTC 2015


Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.591.mcz

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

Name: Collections-mt.591
Author: mt
Time: 14 January 2015, 1:13:09.966 pm
UUID: 8d73a22f-0d76-1f4a-82b7-53900b5f3be1
Ancestors: Collections-mt.590

Added #flatten as special case for #concatenation to remove any nesting except for strings. Very simple implementation with streams and recursion but not as efficient as #concatenation.

=============== Diff against Collections-mt.590 ===============

Item was added:
+ ----- Method: SequenceableCollection>>flatten (in category 'converting') -----
+ flatten
+ 	"Similar to #concatenation but removes all nesting except for strings.
+ Example: {3 .4 .{2 .4 .{'hi'} .'ho'}} flatten = {3 .4 .2 .4 .'hi' .'ho'}"
+ 
+ 	^ Array streamContents: [:stream |
+ 		self do: [:each |
+ 			(each isCollection and: [each isString not])
+ 				ifFalse: [stream nextPut: each]
+ 				ifTrue: [stream nextPutAll: each flatten]]]!



More information about the Squeak-dev mailing list