improve answer substitutions at top-level
This commit is contained in:
@@ -235,7 +235,8 @@ write_eqs_and_read_input(B, VarList) :-
|
|||||||
append([Vars0, AttrVars, AttrGoalVars], Vars),
|
append([Vars0, AttrVars, AttrGoalVars], Vars),
|
||||||
charsio:extend_var_list(Vars, VarList, NewVarList, fabricated),
|
charsio:extend_var_list(Vars, VarList, NewVarList, fabricated),
|
||||||
'$get_b_value'(B0),
|
'$get_b_value'(B0),
|
||||||
gather_equations(NewVarList, NewVarList, Goals, AttrGoals),
|
gather_query_vars(VarList, QueryVars),
|
||||||
|
gather_equations(NewVarList, QueryVars, Goals, AttrGoals),
|
||||||
( bb_get('$first_answer', true) ->
|
( bb_get('$first_answer', true) ->
|
||||||
write(' '),
|
write(' '),
|
||||||
bb_put('$first_answer', false)
|
bb_put('$first_answer', false)
|
||||||
@@ -294,9 +295,30 @@ gather_query_vars([], []).
|
|||||||
|
|
||||||
is_a_different_variable([_ = Binding | Pairs], Value) :-
|
is_a_different_variable([_ = Binding | Pairs], Value) :-
|
||||||
( Value == Binding, !
|
( Value == Binding, !
|
||||||
; is_a_different_variable(Pairs, Var)
|
; is_a_different_variable(Pairs, Value)
|
||||||
).
|
).
|
||||||
|
|
||||||
|
eq_member(X, [Y|_]) :- X == Y, !.
|
||||||
|
eq_member(X, [_|Ys]) :- eq_member(X, Ys).
|
||||||
|
|
||||||
|
gather_equations([], _, Goals, Goals).
|
||||||
|
gather_equations([Var = Value | Pairs], OrigVarList, Goals, Goals1) :-
|
||||||
|
( var(Value) ->
|
||||||
|
( eq_member(Value, OrigVarList),
|
||||||
|
( Pairs == [], NewPairs = []
|
||||||
|
; ( select((OtherVar = OtherValue), Pairs, NewPairs),
|
||||||
|
Value == OtherValue, Var \== OtherVar
|
||||||
|
)
|
||||||
|
) ->
|
||||||
|
Goals = [Var = Value | Goals0],
|
||||||
|
gather_equations(NewPairs, OrigVarList, Goals0, Goals1)
|
||||||
|
; gather_equations(Pairs, OrigVarList, Goals, Goals1)
|
||||||
|
)
|
||||||
|
; Goals = [Var = Value | Goals0],
|
||||||
|
gather_equations(Pairs, OrigVarList, Goals0, Goals1)
|
||||||
|
).
|
||||||
|
|
||||||
|
/*
|
||||||
gather_equations([], MasterList, Goals, Goals).
|
gather_equations([], MasterList, Goals, Goals).
|
||||||
gather_equations([Var = Value | Pairs], MasterList, Goals, Goals1) :-
|
gather_equations([Var = Value | Pairs], MasterList, Goals, Goals1) :-
|
||||||
select((Var = _), MasterList, MasterPairs),
|
select((Var = _), MasterList, MasterPairs),
|
||||||
@@ -307,6 +329,7 @@ gather_equations([Var = Value | Pairs], MasterList, Goals, Goals1) :-
|
|||||||
gather_equations(Pairs, MasterList, Goals0, Goals1)
|
gather_equations(Pairs, MasterList, Goals0, Goals1)
|
||||||
; gather_equations(Pairs, MasterList, Goals, Goals1)
|
; gather_equations(Pairs, MasterList, Goals, Goals1)
|
||||||
).
|
).
|
||||||
|
*/
|
||||||
|
|
||||||
print_exception(E) :-
|
print_exception(E) :-
|
||||||
( E == error('$interrupt_thrown', repl) -> nl % print the
|
( E == error('$interrupt_thrown', repl) -> nl % print the
|
||||||
|
|||||||
Reference in New Issue
Block a user