14 lines
511 B
Fennel
14 lines
511 B
Fennel
(local Sqlog (require :waltz.sqlog))
|
|
(import-macros {: $ : query : insert : delete : update : 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 1] [parent x y])
|
|
([ancestor x y (+ gen 1)] [parent x z] [ancestor z y gen]))
|
|
(pp (update s [p _ (+ y 1)] [p x y] [q x]))
|