Module Tp4
A module for transforming a “Tuple predicate” with 4 arguments.
In qtil speak:
- a “Function” (FnX) is a predicate with a bindingset[] on all of its arguments, and a result
- a "TuplePredicate " (TpX) is a predicate with finite arguments and no result
- a “Relation” (RelX) is a predicate with finite arguments and a finite result
- a “Property” (PropX) is a predicate with a bindingset[] on all arguments no result
Essentially, a tuple predicate Tp<A, B, C> represents a finite set of tuples (a, b, c). This
module accepts a tuple predicate (predicate p(A, B, C)) as an input, and offers functional
programming features on top of it such as map and filter, as well as some relational algebra
features such as projection and joins.
Example:
predicate livesIn(Person p, City c) { c = p.getCity() }
string describe(Person p, City c) { result = p.getName() + " lives in " + c.getName() }
// selects "Peter lives in New York", "Wanda lives in London", ...
select Tp2<Person, City, livesIn/2>::Map<string, describe/2>::find()
Import path
import qtil.fn.generated.TpPredicates
| contains | Checks if (a, b, c, …) is a member of the tuple set represented by this “tuple predicate.” |
| doCount | Count the number of tuples in this tuple set. |
| dropFirst | Drop the first column in the set of tuples that satisfy the given predicate, and get a new tuple set after that column has been dropped. |
| dropFourth | Drop the fourth column in the set of tuples that satisfy the given predicate, and get a new tuple set after that column has been dropped. |
| dropSecond | Drop the second column in the set of tuples that satisfy the given predicate, and get a new tuple set after that column has been dropped. |
| dropThird | Drop the third column in the set of tuples that satisfy the given predicate, and get a new tuple set after that column has been dropped. |
| first | Get the set of first values in the set of tuples that satisfy the given predicate. |
| fourth | Get the set of fourth values in the set of tuples that satisfy the given predicate. |
| second | Get the set of second values in the set of tuples that satisfy the given predicate. |
| third | Get the set of third values in the set of tuples that satisfy the given predicate. |
Modules
| AllHoldsFor | A module with a single predicate, |
| AnyHoldsFor | A module with a single predicate, |
| ContainedBy | A module with a single predicate, |
| ContainsAll | A module with a single predicate, |
| ContainsAny | A module with a single predicate, |
| Difference | Creates a new tuple predicate that holds the elements only in the current tuple set, not the given one. |
| ExtendByFn | Extend this tuple predicate to have an additional column, by running a provided function over each tuple in this predicate’s tuple set, and using the result of that function as the new column. |
| ExtendByRelation | Extend this tuple predicate to have an additional column, by running a provided relation over each tuple in this predicate’s tuple set, and using the result of that relation as the new column. |
| ExtendIntersect | Extend this tuple predicate to have an additional column, by intersecting it with a tuple predicate with one additional parameter and all existing matching. |
| ExtendMapFirst | Maps the set of first values in the set of tuples that satisfy the given predicate, against a mapper function, and use the result to add a column to this tuple set. |
| ExtendMapFourth | Maps the set of fourth values in the set of tuples that satisfy the given predicate, against a mapper function, and use the result to add a column to this tuple set. |
| ExtendMapSecond | Maps the set of second values in the set of tuples that satisfy the given predicate, against a mapper function, and use the result to add a column to this tuple set. |
| ExtendMapThird | Maps the set of third values in the set of tuples that satisfy the given predicate, against a mapper function, and use the result to add a column to this tuple set. |
| ExtendRelateFirst | Maps the set of first values in the set of tuples that satisfy the given predicate, against a mapper function, and use the result to add a column to this tuple set. |
| ExtendRelateFourth | Maps the set of fourth values in the set of tuples that satisfy the given predicate, against a mapper function, and use the result to add a column to this tuple set. |
| ExtendRelateSecond | Maps the set of second values in the set of tuples that satisfy the given predicate, against a mapper function, and use the result to add a column to this tuple set. |
| ExtendRelateThird | Maps the set of third values in the set of tuples that satisfy the given predicate, against a mapper function, and use the result to add a column to this tuple set. |
| Filter | Takes a property which filters the contents of the current tuple set and produces a new one. |
| Intersect | Takes a tuple set and intersects it with the current tuple set to produce a new one. |
| Join2ByFns | A basic, but very flexible join operation, taking a new tuple predicate to join as well as a function for each that maps it to a value of type J. |
| Map | Map a function over the tuples in this tuple set, and get a new tuple predicate back representing the set of tuples after being transformed by that function. |
| MapFirst | Maps the set of first values in the set of tuples that satisfy the given predicate, against a mapper function. |
| MapFourth | Maps the set of fourth values in the set of tuples that satisfy the given predicate, against a mapper function. |
| MapRelateFirst | Maps the set of first values in the set of tuples that satisfy the given predicate, against a mapper relation. |
| MapRelateFourth | Maps the set of fourth values in the set of tuples that satisfy the given predicate, against a mapper relation. |
| MapRelateSecond | Maps the set of second values in the set of tuples that satisfy the given predicate, against a mapper relation. |
| MapRelateThird | Maps the set of third values in the set of tuples that satisfy the given predicate, against a mapper relation. |
| MapSecond | Maps the set of second values in the set of tuples that satisfy the given predicate, against a mapper function. |
| MapThird | Maps the set of third values in the set of tuples that satisfy the given predicate, against a mapper function. |
| Project1 | An alias for |
| Project2 | Project this tuple set to a new tuple set of 2 values per row, by using a set of projection functions. |
| Project3 | Project this tuple set to a new tuple set of 3 values per row, by using a set of projection functions. |
| Project4 | Project this tuple set to a new tuple set of 4 values per row, by using a set of projection functions. |
| Project5 | Project this tuple set to a new tuple set of 5 values per row, by using a set of projection functions. |
| Project6 | Project this tuple set to a new tuple set of 6 values per row, by using a set of projection functions. |
| ProjectRelate1 | An alias for |
| ProjectRelate2 | Project this tuple set to a new tuple set of 2 values per row, by using a set of relations. |
| ProjectRelate3 | Project this tuple set to a new tuple set of 3 values per row, by using a set of relations. |
| ProjectRelate4 | Project this tuple set to a new tuple set of 4 values per row, by using a set of relations. |
| ProjectRelate5 | Project this tuple set to a new tuple set of 5 values per row, by using a set of relations. |
| ProjectRelate6 | Project this tuple set to a new tuple set of 6 values per row, by using a set of relations. |
| Query | Query for the contents of this tuple, by defining a query predicate |
| Relate | Maps a relation over the tuples in this tuple set, and get a new tuple predicate back representing the related values to the tuples in this set. |
| Union | Creates a new tuple predicate that is a union of the current tuple set and the given one. |