Re:Why it’s hard for programmers to write a program to flatt...
by NicoJuicy on Friday February 24, 2017 @12:27PM
(#13725629)
That's almost the exact same code as I thought, but it's an extension on c# and uses 'is Enumerable'. Which language is this?
[ Parent
| on HN ]
Re:Why it’s hard for programmers to write a program to flatt...
by contravariant on Friday February 24, 2017 @12:46PM
(#13725811)
It should work in python 3.3+, provided you make a method isIterable to detect whether something is an iterator or not. For lower versions of python you can't use the phrase 'yield from', so you need to iterate over flatten(y) manually and yield each element.