Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flattening a collection of collections

I am not sure to understand what means the term "flattening" in programming languages. More precisely, what does it mean to "flatten a collection of collections"?

Does it means something like: Collection< Collection< Object >> --> Collection< Object >?

like image 910
Julien Ribon Avatar asked Jul 08 '11 15:07

Julien Ribon


1 Answers

This is some doc.

Also, this might be helpful:

[[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] => [1, 2, 3, 4, 5, 6, 7, 8]

I think an informal definition would be "recursively get all the contents of the current collection and put all the contents into one single collection". Of course, the recursively could be ignored, in which case just one layer would be faltten.

like image 141
zw324 Avatar answered Sep 30 '22 15:09

zw324