diff --git a/solutions/pr1.cql b/solutions/pr1.cql new file mode 100644 index 0000000000000000000000000000000000000000..f9bfb751ab7fe0abaacc7b74c0c67cd81b33533a --- /dev/null +++ b/solutions/pr1.cql @@ -0,0 +1,6 @@ +.in +A:2, # declare input files and their numbers of cols in .in section +B:2 + +.out # statements for the query are in .out section +A x B; # returns the cartesian product of the two sets (conjunction) \ No newline at end of file diff --git a/solutions/pr2.cql b/solutions/pr2.cql new file mode 100644 index 0000000000000000000000000000000000000000..8406adf37f2c403012678ffd61a6539df7291fcd --- /dev/null +++ b/solutions/pr2.cql @@ -0,0 +1,5 @@ +.in +A:3 + +.out +filter((r) -> isSubstring(r[1], r[2])); \ No newline at end of file diff --git a/solutions/pr3.cql b/solutions/pr3.cql new file mode 100644 index 0000000000000000000000000000000000000000..89efa96295a28807a230fc57a3a59fe3965532b4 --- /dev/null +++ b/solutions/pr3.cql @@ -0,0 +1,6 @@ +.in +A:3 + +.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. diff --git a/solutions/pr4.cql b/solutions/pr4.cql new file mode 100644 index 0000000000000000000000000000000000000000..7bfc9d108ca5088b896098c1315b5779c6beba77 --- /dev/null +++ b/solutions/pr4.cql @@ -0,0 +1,9 @@ +.in +P: 4, +Q: 4 + +.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 diff --git a/solutions/pr5.cql b/solutions/pr5.cql new file mode 100644 index 0000000000000000000000000000000000000000..e18dc7a8b79f5f52f8692bc58a74a3e481474a03 --- /dev/null +++ b/solutions/pr5.cql @@ -0,0 +1,5 @@ +.in +A:1 + +.out +map[A](\r -> [r[1],"0",r[1]]); \ No newline at end of file