( start: List<A>, remaining: List<A>, predicate: Predicate<A>, isFlipped: boolean )
| 518 | // everything from 'start' is included, if everything from this point is in we can return the origin |
| 519 | // start otherwise if we discover an element that is out we must create a new partial list. |
| 520 | const allIn = <A>( |
| 521 | start: List<A>, |
| 522 | remaining: List<A>, |
| 523 | predicate: Predicate<A>, |
| 524 | isFlipped: boolean |
| 525 | ): List<A> => { |
| 526 | while (true) { |
| 527 | if (isNil(remaining)) { |
| 528 | return start |
| 529 | } else { |
| 530 | if (predicate(remaining.head) !== isFlipped) { |
| 531 | remaining = remaining.tail |
| 532 | } else { |
| 533 | return partialFill(start, remaining, predicate, isFlipped) |
| 534 | } |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | // we have seen elements that should be included then one that should be excluded, start building |
| 540 | const partialFill = <A>( |
no test coverage detected