diff --git a/solution.pl b/solution.pl index 7a98b6a..509fdaa 100644 --- a/solution.pl +++ b/solution.pl @@ -131,16 +131,18 @@ prompt, but which may include selectors. Selectors are terms of the form delete(Table, Conds) :- (tabl(Table, _) -> row(Table, Row), - does_match(Conds, Table, Row) + does_match(Conds, Table, Row), + Term =.. [Table | Row], + retract(Term), + fail ; throw("Table doesn't exist") - ); true. + ). + +delete(_, _). -does_match([], Table, Row) :- - Term =.. [Table | Row], - retract(Term), - fail. +does_match([], _, _) :- !. does_match([Cond|Rest], Table, Row) :- % Extract the operator, field and value from the condition