From: Nicolas Luck Date: Thu, 20 Jul 2023 22:23:35 +0000 (+0200) Subject: Add missing write_goal/3 to lib_toplevel.pl X-Git-Tag: remove^2~55 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=0b833bd2f3cf0e87d4240b3d6a3953d8050b90f5;p=scryer-prolog.git Add missing write_goal/3 to lib_toplevel.pl --- diff --git a/src/lib_toplevel.pl b/src/lib_toplevel.pl index 3bdb2bb6..70ece273 100644 --- a/src/lib_toplevel.pl +++ b/src/lib_toplevel.pl @@ -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) ->