apoc.coll.pairs

Function

apoc.coll.pairs(list LIST<ANY>) - returns a LIST<ANY> of adjacent elements in the LIST<ANY> ([1,2],[2,3],[3,null]).

Signature

apoc.coll.pairs(list :: LIST<ANY>) :: LIST<ANY>

Input parameters

Name Type Default

list

LIST<ANY>

null

Usage examples

The following creates a list of lists of adjacent elements in a list:

RETURN apoc.coll.pairs([1,2,3,4,5]) AS output;
Table 1. Results
Output

[[1, 2], [2, 3], [3, 4], [4, 5], [5, null]]