qtil
advanced-security/qtil-swift 0.0.3
Search

Module Tp1

A module for transforming a “Tuple predicate” with 1 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.Tp

Predicates

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.

first

Get the set of first values in the set of tuples that satisfy the given predicate.

Modules

AllHoldsFor

A module with a single predicate, holds, that holds if all of the tuples in the current tuple set satisfy the given property prop.

AnyHoldsFor

A module with a single predicate, holds, that holds if any of the tuples in the current tuple satisfy the given property prop.

ContainedBy

A module with a single predicate, holds, that holds if all of the tuples in the current tuple set satisfy the given property prop.

ContainsAll

A module with a single predicate, holds, that holds if the current tuple set contains all of the tuples of the given tuple predicate tp2.

ContainsAny

A module with a single predicate, holds, that holds if the current tuple set contains any of the tuples of the given tuple predicate tp2.

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.

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.

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.

Join3ByFns

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.

Join4ByFns

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.

Join5ByFns

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.

MapRelateFirst

Maps the set of first values in the set of tuples that satisfy the given predicate, against a mapper relation.

Project1

An alias for Map, but the result is a “tuple set” (a predicate(A a) with one parameter and no result) instead of a ResultSet (a predicate R pred() with no parameters and result R).

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 Relate, but the result is a “tuple set” (a predicate(A a) with one parameter and no result) instead of a ResultSet (a predicate R pred() with no parameters and result R).

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 tpQuery to import.

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.

Parameters