Vars#
relationalai.std
#Vars(count: int) -> Instance | List[Instance]
Creates count
number of Instance
objects representing unknown values.
Must be called in a rule or query.
Parameters#
Name | Type | Description |
---|---|---|
count | int | The number of variables to create. |
Returns#
An Instance
object or a list
of Instance
objects.
Example#
You must call Vars()
from within a rule or query:
#import relationalai as rai
from relationalai.std import Vars
model = rai.Model("people")
Person = model.Type("Person")
with model.rule():
Person.add(name="Joe", age=41)
Person.add(name="Jane", age=39)
with model.query() as select:
person = Person()
x = Vars(1)
person.age == x
x > 40
response = select(person.name, x)
print(response.results)
# Output:
# name v
# 0 Joe 41