|| apoc.coll.pairWithOffset - APOC 核心文档 - Neo4j 文档

apoc.coll.pairWithOffset

这既是函数也是过程。

函数详情

详情

语法

apoc.coll.pairWithOffset(coll, offset)

描述

返回由偏移量定义的 LIST<ANY> 对列表。

参数

名称

类型

描述

coll

LIST<ANY>

用于创建对的列表。

offset

INTEGER

从给定列表中创建每对的偏移量。

返回

LIST<ANY>

过程详情

详情

语法

apoc.coll.pairWithOffset(coll, offset) :: (value)

描述

返回由偏移量定义的 LIST<ANY> 对列表。

输入参数

名称

类型

描述

coll

LIST<ANY>

用于创建对的列表。

offset

INTEGER

从给定列表中创建每对的偏移量。

返回参数

名称

类型

描述

LIST<ANY>

创建的对。

使用示例

以下返回由偏移量定义的对列表

apoc.coll.pairWithOffset
WITH [1,2,3,4] AS list, 2 AS offset
RETURN apoc.coll.pairWithOffset(list, offset) AS value
Cypher 的列表推导
WITH [1,2,3,4] AS list, 2 AS offset
RETURN [i IN range(0, size(list) - 1) | [list[i], list[i + offset]]] AS value
结果

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

它也可用作过程

apoc.coll.pairWithOffset
WITH [1,2,3,4] AS list, 2 AS offset
CALL apoc.coll.pairWithOffset(list, offset)
YIELD value
RETURN value
Cypher 的 UNWIND
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
结果

[1,3]

[2,4]

[3,null]

[4,null]

© . This site is unofficial and not affiliated with Neo4j, Inc.