They say: if you want something done right, do it
yourself. So... :)
I added a #deepFlatten message in the Collection protocol in *collectionextensions.
See the tests for the specs
In short, deepFlatten doesn't mind flat collections as well as multi-level
collecions.
#( (1 2) ( (4 5) 3) ) deepFlatten --> #(1 2 4 5 3)
#( 5 ( (3) ) ) deepFlatten --> #(5 3)
It also preserves strings
#( ('foo' ('bar') ) 'zorg' ) deepFlatten --> #('foo'
'bar' 'zorg')
On 4 févr. 2011, at 18:39, Simon Denier wrote:
I'm a bit surpised...
I want to flatten a collection with 'mixed' entries, like this one {{1. 2. 3}. 4}
-> {1. 2. 3. 4}
However it appears that #flatten does not work, because it expects that all elements in
the collection are themselves collections.
so
{{1. 2. 3}. {4}} flatten -> {1. 2. 3. 4} works
but
{{1. 2. 3}. 4} flatten -> raises error because of a dnu on 4
Anyone knows the right method which would work for my case?
--
Simon Denier
--
Simon Denier
_______________________________________________
Moose-dev mailing list
Moose-dev(a)iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
"Don't give to get. Just give."