pet-names.taq

$ java -jar taq.jar pet-names

Running query pets in global scope 
Lassie
Cuddles
Bruiser
Rex
Pixie
Axel
Amiele
Fido

Running query reverse_pets in global scope 
Fido
Amiele
Axel
Pixie
Rex
Bruiser
Cuddles
Lassie

Description

pet-names.taq contrasts a forward cursor to a reverse cursor. Query “pets” progresses in the forward direction, and the “pet” cursor increments

pet++

Reaching the end of the “pets_info” list is easy to detect

? fact pet

The keyword reverse is used to nagivate the “pet_info” list in reverse and the the “pet” cursor decrements

reverse cursor pet(pets_info)
… ? pet–


flow pets
{ export list<string> pet_names }
(
cursor<axiom> pet(pet_data),
{
? fact pet,
pet_names += pet->name,
pet++
}
)

flow reverse_pets
{ export list<string> pet_names }
(
reverse cursor<axiom> pet(pet_data),
{
? fact pet,
pet_names += pet->name,
pet--
}
)

axiom list pet_data(species, name, color)
{ "dog", "Lassie", "blonde" }
{ "cat", "Cuddles", "tortoise" }
{ "Dog", "Bruiser", "brindle" }
{ "Dog", "Rex", "black and tan" }
{ "Cat", "Pixie", "black" }
{ "dog", "Axel", "white" }
{ "Cat", "Amiele", "ginger" }
{ "dog", "Fido", "brown" }

query pets(list pet_data : pets)

query reverse_pets(list pet_data : reverse_pets)