high-cities-dynamic.taq

$ java -jar taq.jar high-cities-dynamic

Running query cities in global scope 
high_cities(name=addis ababa, altitude=8000)
high_cities(name=denver, altitude=5280)
high_cities(name=flagstaff, altitude=6970)
high_cities(name=leadville, altitude=10200)

Description

high-cities-dynamic.taq demonstrates exporting an axiom list as a means to returning a query result. This approach allows the axiom list to be accessed while processing the query. It also provides a channel to output additional information from a query such as statistics. However, this example just shows how to export a list.

The first term of the “high_city” is a dynamic axiom list declaration wuth an export qualification

export list<axiom> high_cities

It is progressively populated as each high city is encountered from the incoming “city” axiom list. The list is accessed from the query result using the full name of the list as the key, which in this case is “high_cdy.high_cities”.


axiom list city (name, altitude)
{"bilene", 1718}
{"addis ababa", 8000}
{"denver", 5280}
{"flagstaff", 6970}
{"jacksonville", 8}
{"leadville", 10200}
{"madrid", 1305}
{"richmond",19}
{"spokane", 1909}
{"wichita", 1305}

// Template to export a high city list
template high_city
{ export list<axiom> high_cities }
(
altitude? > 5000,
high_cities +=
axiom high_city name , altitude }
)

query cities(city : high_city)