Template-Axiom-Query (TAQ)

Query Call

A query call is directed to to either a query, template or flow and is another operation having a function format. The function name corresponds to the target name and the return type is determined by the target. In the case of the target being a template or flow, an axiom is always returned. Any function parameters are formed into an axiom to be unified with the target as an initial step.

Query target

birds2.taq demonstrates a call to the "waterfowl" query of birds.taq. This query returns an axiom list which is assigned to a cursor to allow iteration over the list

cursor<axiom> waterfowl_order = waterfowl(),

Note that a "list_non_blanks" library function filters out non-blank terms and returns a string list.

Template target

circum.taq calculates the circumference of a circle given it's radius with the help of a call to a template named "x_by_factor". This multiplies 2 decimals "x" and "factor". In this case, x is the radius and factor is the number pi (3.14). The returned value is an axiom with a single term named "product", the value of which is multiplied by 2 to give the required answer.

scope math
{
template<term> x_by_factor
{
decimal factor,
decimal x
}
(
decimal product = x * factor
)
}

flow radius_by_2pi
{ decimal radius }
(
. decimal pi_times_radius =
math.x_by_factor(pi = decimal 3.14, radius)
->product,
circumference = 2 * pi_times_radius
)

query<term> circumference(radius_by_2pi)

Template returning axiom list

query-student-scores.taq demonstrates a call to a "report" template which converts one or more numerical grades to alpha grades. This template is placed in the "school" scope to mimic the way a library function is called using a 2-part name.

The school.report() call returns an axiom list in a term named "subjects" and is extracted using a right arrow term reference:

cursor<axiom> subjects =
school.report(english, maths, history)
->subjects

Note function-student-scores.tqa declared an archetype to define a function call return type, but the archetype is automatically provided with a query call,