Skip to content

Commit

Permalink
refactor: rewrite List/Flatten to be tail-recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Oct 10, 2021
1 parent 402ecab commit acaa987
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sources/List/Flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {Boolean} from '../Boolean/_Internal'
/**
* @hidden
*/
type __Flatten<L extends List, LO extends List, strict extends Boolean, limit extends Iteration, I extends Iteration = IterationOf<0>> = {
0: __Flatten<_UnNest<L, strict>, L, strict, limit, Next<I>>
1: L
}[Or<Equals<L, LO>, Extends<limit, I>>]
type __Flatten<L extends List, LO extends List, strict extends Boolean, limit extends Iteration, I extends Iteration =
IterationOf<0>> = Or<Equals<L, LO>, Extends<limit, I>> extends 0
? __Flatten<_UnNest<L, strict>, L, strict, limit, Next<I>>
: L

/**
* @hidden
Expand Down

0 comments on commit acaa987

Please sign in to comment.