[squeak-dev] The Trunk: Collections-mt.591.mcz
Tobias Pape
Das.Linux at gmx.de
Wed Jan 14 12:36:10 UTC 2015
Heym
On 14.01.2015, at 12:13, commits at source.squeak.org wrote:
> 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
I know that flatten is a name for this in other languages
but IMHO `flattened` would be a better fit :)
(see #sorted, #negated, #rounded, ...)
I would expect in-place, destructive operation when reading
`flatten`, eg as with #sort
Best
-Tobias
> + "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
|