apoc.coll.pairWithOffset
This is both a function and a procedure.
Function Details
Syntax |
|
||
Description |
Returns a |
||
Arguments |
Name |
Type |
Description |
|
|
The list to create pairs from. |
|
|
|
The offset to make each pair with from the given list. |
|
Returns |
|
Procedure Details
Syntax |
|
||
Description |
Returns a |
||
Input arguments |
Name |
Type |
Description |
|
|
The list to create pairs from. |
|
|
|
The offset to make each pair with from the given list. |
|
Return arguments |
Name |
Type |
Description |
|
|
The created pair. |
Usage examples
The following returns a list of pairs defined by the offset:
WITH [1,2,3,4] AS list, 2 AS offset
RETURN apoc.coll.pairWithOffset(list, offset) AS value
WITH [1,2,3,4] AS list, 2 AS offset
UNWIND range(0, size(list) - 1) AS x
RETURN collect([list[x], list[x + offset]]) AS value
value |
---|
[[1,3],[2,4],[3,null],[4,null]] |
It works also as procedure:
WITH [1,2,3,4] AS list, 2 AS offset
CALL apoc.coll.pairWithOffset(list, offset)
YIELD value
RETURN value
WITH [1,2,3,4] AS list, 2 AS offset
UNWIND range(0, size(list) - 1) AS x
RETURN [list[x], list[x + offset]] AS value
value |
---|
[1,3] |
[2,4] |
[3,null] |
[4,null] |