apoc.coll.pairsMin

Details

Syntax

apoc.coll.pairsMin(list)

Description

Returns LIST<ANY> values of adjacent elements in the LIST<ANY> ([1,2],[2,3]), skipping the final element.

Arguments

Name

Type

Description

list

LIST<ANY>

The list to create pairs from.

Returns

LIST<ANY>

Usage examples

The following examples create a list of lists, where each nested list contains adjacent element pairs from the input list, skipping the last adjacent pair ([5, null] in this example), using both APOC and Cypher:

apoc.coll.pairsMin
RETURN apoc.coll.pairsMin([1,2,3,4,5]) AS output;
Cypher’s UNWIND
WITH [1,2,3,4,5] AS list
RETURN [i IN range(0, size(list) - 2) | [list[i], list[i + 1]]] AS value
Results
Output

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