charsio:extend_var_list(Vars, VarList, NewVarList, fabricated),
'$get_b_value'(B0),
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) ->
write(' '),
bb_put('$first_answer', false)
( Goals == [] ->
write('true.'), nl
; thread_goals(Goals, ThreadedGoals, (',')),
- write_eq(ThreadedGoals, NewVarList, 20),
+ write_eq(ThreadedGoals, NewVarList0, 20),
write('.'),
nl
)
; thread_goals(Goals, ThreadedGoals, (',')),
- write_eq(ThreadedGoals, NewVarList, 20),
- read_input(ThreadedGoals, NewVarList)
+ write_eq(ThreadedGoals, NewVarList0, 20),
+ read_input(ThreadedGoals, NewVarList0)
).
read_input(ThreadedGoals, NewVarList) :-
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) :-
+select_all([], _, _, [], []).
+select_all([OtherVar = OtherValue | Pairs], Var, Value, Vars, NewPairs) :-
+ ( OtherValue == Value ->
+ Vars = [OtherVar = OtherValue | Vars0],
+ select_all(Pairs, Var, Value, Vars0, NewPairs)
+ ;
+ NewPairs = [OtherVar = OtherValue | NewPairs0],
+ select_all(Pairs, Var, Value, Vars, NewPairs0)
+ ).
+
+gather_equations([], _, []).
+gather_equations([Var = Value | Pairs], OrigVarList, Goals) :-
( 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)
+ select_all(Pairs, Var, Value, [_ | VarEqs], NewPairs) ->
+ append([Var = Value | VarEqs], Goals0, Goals),
+ gather_equations(NewPairs, OrigVarList, Goals0)
+ ;
+ gather_equations(Pairs, OrigVarList, Goals)
)
- ; Goals = [Var = Value | Goals0],
- gather_equations(Pairs, OrigVarList, Goals0, Goals1)
- ).
-
-/*
-gather_equations([], MasterList, Goals, Goals).
-gather_equations([Var = Value | Pairs], MasterList, Goals, Goals1) :-
- ( ( nonvar(Value)
- ; select((Var = _), MasterList, MasterPairs),
- is_a_different_variable(MasterPairs, Value)
- ) ->
+ ;
Goals = [Var = Value | Goals0],
- gather_equations(Pairs, MasterList, Goals0, Goals1)
- ; gather_equations(Pairs, MasterList, Goals, Goals1)
+ gather_equations(Pairs, OrigVarList, Goals0)
).
-*/
print_exception(E) :-
( E == error('$interrupt_thrown', repl) -> nl % print the
)
; Goals1 = Goals0
).
-