Skip to content

Commit f2d18ca

Browse files
committed
Fix empty result handling by the metta_call function
1 parent 329dec4 commit f2d18ca

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/metta.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,15 @@ if <$op is executable grounded atom>:
535535
case IncorrectArgument:
536536
return [($atom, $bindings)]
537537
else:
538-
for $rb in query($space, (= $atom $X)):
539-
for $mb in merge_bindings($rb, $bindings):
540-
if not(<$mb has loop bindings>) and <$mb contains value for the $X variable>:
541-
$x = <get value of the $X variable from $mb>
542-
$results += [metta($x, $type, $space, $mb)]
538+
$query_output = query($space, (= $atom $X))
539+
if len($query_output) > 0:
540+
for $rb in $query_output:
541+
for $mb in merge_bindings($rb, $bindings):
542+
if not(<$mb has loop bindings>) and <$mb contains value for the $X variable>:
543+
$x = <get value of the $X variable from $mb>
544+
$results += [metta($x, $type, $space, $mb)]
545+
else:
546+
$results += [($atom, $bindings)]
543547
544548
if len($results) == 0:
545549
return [(Empty, $bindings)]

0 commit comments

Comments
 (0)