plug missing variables in equations (#488), exclude/3 regression (#452), incorrect answer substitution (#326)
This commit is contained in:
@@ -238,7 +238,11 @@ write_eqs_and_read_input(B, VarList) :-
|
|||||||
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_query_vars(VarList, OrigVars),
|
gather_query_vars(VarList, OrigVars),
|
||||||
gather_equations(NewVarList, OrigVars, Goals, AttrGoals),
|
gather_equations(NewVarList, OrigVars, Equations),
|
||||||
|
append(Equations, AttrGoals, Goals),
|
||||||
|
term_variables(Equations, EqVars0),
|
||||||
|
append([EqVars0, AttrVars, AttrGoalVars], Vars1),
|
||||||
|
charsio:extend_var_list(Vars1, VarList, NewVarList0, fabricated),
|
||||||
( bb_get('$first_answer', true) ->
|
( bb_get('$first_answer', true) ->
|
||||||
write(' '),
|
write(' '),
|
||||||
bb_put('$first_answer', false)
|
bb_put('$first_answer', false)
|
||||||
@@ -248,13 +252,13 @@ write_eqs_and_read_input(B, VarList) :-
|
|||||||
( Goals == [] ->
|
( Goals == [] ->
|
||||||
write('true.'), nl
|
write('true.'), nl
|
||||||
; thread_goals(Goals, ThreadedGoals, (',')),
|
; thread_goals(Goals, ThreadedGoals, (',')),
|
||||||
write_eq(ThreadedGoals, NewVarList, 20),
|
write_eq(ThreadedGoals, NewVarList0, 20),
|
||||||
write('.'),
|
write('.'),
|
||||||
nl
|
nl
|
||||||
)
|
)
|
||||||
; thread_goals(Goals, ThreadedGoals, (',')),
|
; thread_goals(Goals, ThreadedGoals, (',')),
|
||||||
write_eq(ThreadedGoals, NewVarList, 20),
|
write_eq(ThreadedGoals, NewVarList0, 20),
|
||||||
read_input(ThreadedGoals, NewVarList)
|
read_input(ThreadedGoals, NewVarList0)
|
||||||
).
|
).
|
||||||
|
|
||||||
read_input(ThreadedGoals, NewVarList) :-
|
read_input(ThreadedGoals, NewVarList) :-
|
||||||
@@ -303,35 +307,30 @@ is_a_different_variable([_ = Binding | Pairs], Value) :-
|
|||||||
eq_member(X, [Y|_]) :- X == Y, !.
|
eq_member(X, [Y|_]) :- X == Y, !.
|
||||||
eq_member(X, [_|Ys]) :- eq_member(X, Ys).
|
eq_member(X, [_|Ys]) :- eq_member(X, Ys).
|
||||||
|
|
||||||
gather_equations([], _, Goals, Goals).
|
select_all([], _, _, [], []).
|
||||||
gather_equations([Var = Value | Pairs], OrigVarList, Goals, Goals1) :-
|
select_all([OtherVar = OtherValue | Pairs], Var, Value, Vars, NewPairs) :-
|
||||||
( var(Value) ->
|
( OtherValue == Value ->
|
||||||
( eq_member(Value, OrigVarList),
|
Vars = [OtherVar = OtherValue | Vars0],
|
||||||
( Pairs == [], NewPairs = []
|
select_all(Pairs, Var, Value, Vars0, NewPairs)
|
||||||
; ( select((OtherVar = OtherValue), Pairs, NewPairs),
|
;
|
||||||
Value == OtherValue, Var \== OtherVar
|
NewPairs = [OtherVar = OtherValue | NewPairs0],
|
||||||
)
|
select_all(Pairs, Var, Value, Vars, NewPairs0)
|
||||||
) ->
|
|
||||||
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([], _, []).
|
||||||
gather_equations([], MasterList, Goals, Goals).
|
gather_equations([Var = Value | Pairs], OrigVarList, Goals) :-
|
||||||
gather_equations([Var = Value | Pairs], MasterList, Goals, Goals1) :-
|
( var(Value) ->
|
||||||
( ( nonvar(Value)
|
( eq_member(Value, OrigVarList),
|
||||||
; select((Var = _), MasterList, MasterPairs),
|
select_all(Pairs, Var, Value, [_ | VarEqs], NewPairs) ->
|
||||||
is_a_different_variable(MasterPairs, Value)
|
append([Var = Value | VarEqs], Goals0, Goals),
|
||||||
) ->
|
gather_equations(NewPairs, OrigVarList, Goals0)
|
||||||
|
;
|
||||||
|
gather_equations(Pairs, OrigVarList, Goals)
|
||||||
|
)
|
||||||
|
;
|
||||||
Goals = [Var = Value | Goals0],
|
Goals = [Var = Value | Goals0],
|
||||||
gather_equations(Pairs, MasterList, Goals0, Goals1)
|
gather_equations(Pairs, OrigVarList, Goals0)
|
||||||
; 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
|
||||||
@@ -476,4 +475,3 @@ thread_goals(Goals0, Goals1, Functor) :-
|
|||||||
)
|
)
|
||||||
; Goals1 = Goals0
|
; Goals1 = Goals0
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user