]> Repositorios git - scryer-prolog.git/commitdiff
Add missing write_goal/3 to lib_toplevel.pl
authorNicolas Luck <[email protected]>
Thu, 20 Jul 2023 22:23:35 +0000 (00:23 +0200)
committerNicolas Luck <[email protected]>
Thu, 20 Jul 2023 22:23:35 +0000 (00:23 +0200)
src/lib_toplevel.pl

index 3bdb2bb6a0331f5cad54143c8065173193bd54f9..70ece27320246c9ea45cc2f5e3e0e36cf867ec81 100644 (file)
@@ -50,6 +50,26 @@ needs_bracketing(Value, Op) :-
        memberchk(EqSpec, [fx,xfx,yfx])
     ).
 
+write_goal(G, VarList, MaxDepth) :-
+    (  G = (Var = Value) ->
+       (  var(Value) ->
+          select((Var = _), VarList, NewVarList)
+       ;  VarList = NewVarList
+       ),
+       write(Var),
+       write(' = '),
+       (  needs_bracketing(Value, (=)) ->
+          write('('),
+          write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth)]),
+          write(')')
+       ;  write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth)])
+       )
+    ;  G == [] ->
+       write('true')
+    ;  write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth)])
+    ).
+
+
 write_last_goal(G, VarList, MaxDepth) :-
     (  G = (Var = Value) ->
        (  var(Value) ->