diff --git a/solutions/pr3.cql b/solutions/pr3.cql index 89efa96295a28807a230fc57a3a59fe3965532b4..7bfc9d108ca5088b896098c1315b5779c6beba77 100644 --- a/solutions/pr3.cql +++ b/solutions/pr3.cql @@ -1,6 +1,9 @@ .in -A:3 +P: 4, +Q: 4 .out -filter (\r -> r[2] == r[3]); # data the the function works on (e.g. input set this time) goes in [], extra info (e.g. predicate in this case) goes in () -map(\r -> r[3,1]); # can also be map[\_](\r ...), where \_ is output of last operation. +P x Q; +filter(\r -> r[4] == r[5]); +let func f(x,y) = if (empty(x)) then y else x; +map(\r -> [r[1], f(r[2], r[6]), f(r[3], r[7]), f(r[4], r[8])); \ No newline at end of file diff --git a/solutions/pr4.cql b/solutions/pr4.cql index 7bfc9d108ca5088b896098c1315b5779c6beba77..b69b87904c44e219df79f4aab05ceb291f0d57dc 100644 --- a/solutions/pr4.cql +++ b/solutions/pr4.cql @@ -1,9 +1,5 @@ .in -P: 4, -Q: 4 +A:2 .out -P x Q; -filter(\r -> r[4] == r[5]); -let func f(x,y) = if (empty(x)) then y else x; -map(\r -> [r[1], f(r[2], r[6]), f(r[3], r[7]), f(r[4], r[8])); \ No newline at end of file +filter (\(r) -> notEmpty(r[2])) \ No newline at end of file