(self: Stream<A, E, R>)
| 3676 | * @since 2.0.0 |
| 3677 | */ |
| 3678 | export const zipWithPrevious = <A, E, R>(self: Stream<A, E, R>): Stream<[Option.Option<A>, A], E, R> => |
| 3679 | mapAccumArray(self, Option.none<A>, (acc, arr) => { |
| 3680 | const pairs = Arr.empty<[Option.Option<A>, A]>() |
| 3681 | for (let i = 0; i < arr.length; i++) { |
| 3682 | const value = arr[i] |
| 3683 | pairs.push([acc, value]) |
| 3684 | acc = Option.some(arr[i]) |
| 3685 | } |
| 3686 | return [acc, pairs] |
| 3687 | }) |
| 3688 | |
| 3689 | /** |
| 3690 | * Zips each element with its previous and next values. |