Yes, multiple times in multiple languages. C, C++, Javascript... sometimes "npm install" is not the answer.
It is reasonable to ask, if a programmer cannot flatten a list, in what sense is that person a programmer? Putting aside the question of whether this is a good approach to recruiting, if this question is being failed with any regularity, it raises some interesting and important questions about the innate difficulty of programming and/or the methods by which it is taught.
Google
Copy
Paste
Algorithm, are they a programmer? Are they more or less of a programmer if instead they use racket or clojure's built-in =flatten=?Came in handy when working with rom archives that liked to put everything in its own folder, and a couple of times when I just had a bunch of crap that I didn't want to have to manually dig up anymore.
Other than that? No, not really.
I had to write this function to flatten a tree of expressions, so I could sort them by precedence, etc and fold them into a tree. I already had a bunch of higher-order primitives for constructing a parser and that was basically a lazy hack for me to get expressions parsed. I eventually implemented a proper expression parser, that was basically the same thing, but produced a flat list from the beginning.
OTOH, in functional programming languages and frameworks, there is no need to actually write a method that does that since it is usually a library function call.
List<List<Blah>> records;
We would send a request off to multiple services, wait for all the responses and then the front end would sometimes need all of the lists and other times need it flatten.
How would I do it?
var allitems = records.SelectMany(b => b).ToList();