nquery/rec ( goal-def/defs n/f -- bindings-array/success? )


Vocabulary
logic.private

Inputs
goal-def/defsan object
n/fan object


Outputs
bindings-array/success?an object


Definition


:: nquery/rec
( goal-def/defs n/f -- bindings-array/success? )
*trace?* get-global :> trace? 0 :> n! f :> success?!
V{ } clone :> bindings [
goal-def/defs normalize [| env |
env table>> keys [ get NORMAL-LOGIC-VAR? ] filter
[ dup env at ] H{ } map>assoc trace? get-global
[ dup [ "%u: %u\n" printf ] assoc-each ] when
bindings push t success?! n/f
[ n 1 + n! n n/f >= [ return ] when ] when
] (resolve)
] with-return bindings dup
{ [ empty? ] [ first keys empty? ] } 1||
[ drop success? ] [ >array ] if ;