DEV Community

Indigo Norrbottenspets
Indigo Norrbottenspets

Posted on

Neo4j: List expressions

size($list)
Enter fullscreen mode Exit fullscreen mode

Number of elements in the list.

reverse($list)
Enter fullscreen mode Exit fullscreen mode

Reverse the order of the elements in the list.

head($list), last($list), tail($list)
Enter fullscreen mode Exit fullscreen mode

head() returns the first, last() the last element of the list. tail() returns all but the first element. All return null for an empty list.

[x IN list | x.prop]
Enter fullscreen mode Exit fullscreen mode

A list of the value of the expression for each element in the original list.

[x IN list WHERE x.prop <> $value]
Enter fullscreen mode Exit fullscreen mode

A filtered list of the elements where the predicate is true.

[x IN list WHERE x.prop <> $value | x.prop]
Enter fullscreen mode Exit fullscreen mode

A list comprehension that filters a list and extracts the value of the expression for each element in that list.

reduce(s = "", x IN list | s + x.prop)
Enter fullscreen mode Exit fullscreen mode

Evaluate expression for each element in the list, accumulate the results.

Useful links

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay