Re:Why it’s hard for programmers to write a program to flatt...
by Qcombinator on Friday February 24, 2017 @02:33PM
(#13726915)
>The perl example cited here kind of blows my mind compare to the trivial python approach
That's because the Perl version is a two-for-one deal: just for fun, Cestith threw in a non-recursive version too. The 'trivial' recursive approach is more or less equivalent to the Python:
sub flatten { map ref($_)? flatten(@$_) : $_, @_ }
That's because the Perl version is a two-for-one deal: just for fun, Cestith threw in a non-recursive version too. The 'trivial' recursive approach is more or less equivalent to the Python: