// general programming in Cypher WITH 5 AS number RETURN CASE WHEN number > 0 THEN toString(number) + " is positive" WHEN number < 0 THEN toString(number) + " is negative" ELSE toString(number) + " is zero" END AS result; WITH [1, 2, 3, 4, 5] AS numbers RETURN [x IN numbers | x * 10] AS new_numbers; WITH [1, 2, 3, 4, 5, 6] AS numbers RETURN [x IN numbers WHERE x % 2 = 0 | x] AS even_numbers; WITH [1, 2, 3, 4, 5] AS numbers RETURN [x IN numbers WHERE x > 3 | x] AS selected_numbers; WITH [[1,2], [3,4], [5,6]] AS numbers RETURN [pair IN numbers | [x IN pair | x * x]] AS square_numbers; WITH [-2, -1, 0, 1, 2] AS numbers RETURN [x IN numbers | CASE WHEN x > 0 THEN "positive" WHEN x < 0 THEN "negative" ELSE "zero" END ] AS classification; // requires Czech Royal Dynasty MATCH path = (a:Person)-[:father|mother*]->(b:Person) WHERE b.name = "Ludmila" RETURN [n IN nodes(path) | n.name] AS mother_line , length(path) as generation , a.dynasty as dynasty ORDER BY a.born; MATCH path = (a:Person)-[:father|mother*]->(b:Person) WHERE b.name = "Ludmila" WITH a, nodes(path) as nodes, relationships(path) as relationships, range(length(path)-1 , 0 , -1) as range RETURN a.name as person , "Ludmila was " + apoc.text.join([i in range | type(relationships[i]) + " of " + (nodes[i]).name] , " who was ") as line_from_Ludmila , a.dynasty as dynasty ORDER BY a.born;