2 ms·
You could reproduce that behaviour of 'flat' by doing something like: function flatten(x, n=1) { return n > 0 ? x.flatmap(y => flatten(y, n-1))
by contravariant 7y ago
You could reproduce that behaviour of 'flat' by doing something like:
function flatten(x, n=1) {
return n > 0 ? x.flatmap(y => flatten(y, n-1))
: x;
}
- masklinn 7y agoYou could also blow up your stack as there is no requirement whatsoever that javascript implementations be tail-recursive.