gaming.taq

java -jar taq.jar gaming

Running query gamble in global scope 
spin(apple, orange, lemon, banana)
spin(lemon, banana, orange, apple)
spin(banana, orange, lemon, apple)

Description

gaming.taq demonstrates dynamic axiom list initialization with parameters. In this case the parameters are 3 pseudo-generated random numbers to achieve an unpredictable result of every query. The example console output shown above is just one of innumerable fruit permutations.

The parameters r1, r2 and r3 are set before, and separately from, the “crank” axiom list which depends on them, so both are placed in the “machine” scope to indicate they are associated. The query therefore provides an example of using a 2-part name to reference the axiom source

query<axiom> gamble(machine.crank : spin)


scope machine {

term r1 = random(4)
term r2 = random(4)
term r3 = random(4)

list<axiom> crank
( i1, i2, i3, i4 )
{ 3^r1, 2^r1, 0^r1, 1^r1 }
{ 0^r2, 1^r2, 2^r2, 3^r2 }
{ 2^r3, 1^r3, 3^r3, 0^r3 }
}

axiom fruit() {"apple", "orange", "banana", "lemon"}

template spin
(
fruit[i1], fruit[i2], fruit[i3], fruit[i4]
)

query<axiom> gamble(machine.crank : spin)