Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/itertools/more-itertools.ts>pairwise

🦕 A TypeScript port of Python's itertools and more-itertools for Deno
Go to Latest
function pairwise
import { pairwise } from "https://deno.land/x/itertools@v1.1.1/more-itertools.ts";

Returns an iterator of paired items, overlapping, from the original. When the input iterable has a finite number of items n, the outputted iterable will have n - 1 items.

>>> pairwise([8, 2, 0, 7])
[(8, 2), (2, 0), (0, 7)]

Parameters

iterable: Iterable<T>

Returns

Iterable<[T, T]>