apoc.coll.pairs

Details

Syntax

apoc.coll.pairs(list)

Description

Returns a LIST<ANY> of adjacent elements in the LIST<ANY> ([1,2],[2,3],[3,null]).

Arguments

Name

Type

Description

list

LIST<ANY>

The list to create pairs from.

Returns

LIST<ANY>

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;
Results
Output

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