Handbook
Glossary
nquery/rec ( goal-def/defs n/f -- bindings-array/success? )
Vocabulary
logic
.
private
Inputs
goal-def/defs
an
object
n/f
an
object
Outputs
bindings-array/success?
an
object
Definition
USING:
accessors
arrays
assocs
combinators.short-circuit
continuations
formatting
kernel
math
namespaces
sequences
;
IN:
logic.private
::
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
;