18 lines
571 B
Plaintext
18 lines
571 B
Plaintext
|
(local Sqlog (require :sqlog))
|
||
|
(import-macros {: $ : query : specify} :sqlog.macros)
|
||
|
|
||
|
(local s (Sqlog))
|
||
|
(s:deftable :parent :parent :child)
|
||
|
(specify 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])
|
||
|
[parent :bob "bob jr"]
|
||
|
[parent "bob jr" "bob iii"]
|
||
|
[parent :bob :fred]
|
||
|
[parent :fred :jim]
|
||
|
[parent :fred :betty])
|
||
|
(pp (query s [generation :bob descendant gen]))
|
||
|
|