Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.687.mcz==================== Summary ====================
Name: Collections-mt.687
Author: mt
Time: 12 April 2016, 11:26:12.382799 am
UUID: e2089a91-178b-ab42-8e57-a71bfb023e74
Ancestors: Collections-mt.686
Support flatten across nested collections and streams.
=============== Diff against Collections-mt.686 ===============
Item was changed:
----- 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]) or: [each isStream])
- (each isCollection and: [each isString not])
ifFalse: [stream nextPut: each]
ifTrue: [stream nextPutAll: each flatten]]]!
Item was added:
+ ----- Method: Stream>>flatten (in category 'converting') -----
+ flatten
+
+ ^ Generator on: [:g |
+ [self atEnd] whileFalse: [
+ self next in: [:object |
+ ((object isCollection and: [object isString not]) or: [object isStream])
+ ifFalse: [g yield: object]
+ ifTrue: [object flatten do: [:each | g yield: each]]]]]!
Item was added:
+ ----- Method: Stream>>flattened (in category 'converting') -----
+ flattened
+ "An alias for #flatten
+ This message's name is in line with messages like #sorted or #reversed
+ while #flatten's is in line with #reverse (as per ANSI, see comment there)"
+
+ ^ self flatten!