Jeremy Penner
82d04e0649
* rule expression generation was miscounting the number of parameters * allow using arbitrary expressions in the head of a rule
15 lines
474 B
Fennel
15 lines
474 B
Fennel
(local Sqlog (require :waltz.sqlog))
|
|
(import-macros {: $ : query : defrules} :waltz.macros)
|
|
|
|
(local s (Sqlog))
|
|
(s:deftable :parent :parent :child)
|
|
(s:deftable :p :x :y)
|
|
(s:deftable :q :z)
|
|
(defrules s
|
|
([generation name (|| name " jr") 2] [parent name (|| name " jr")])
|
|
([generation name (|| name " iii") 3] [ancestor name (|| name " iii")])
|
|
([ancestor x y] [parent x y])
|
|
([ancestor x y] [parent x z] [ancestor z y]))
|
|
(pp (query s [generation "bob" descendant nth]))
|
|
|