Move deletion logic to delete/2
This commit is contained in:
parent
d5351f3dee
commit
eeaba5ee46
18
solution.pl
18
solution.pl
|
@ -131,16 +131,18 @@ prompt, but which may include selectors. Selectors are terms of the form
|
||||||
delete(Table, Conds) :-
|
delete(Table, Conds) :-
|
||||||
(tabl(Table, _) ->
|
(tabl(Table, _) ->
|
||||||
row(Table, Row),
|
row(Table, Row),
|
||||||
does_match(Conds, Table, Row)
|
does_match(Conds, Table, Row),
|
||||||
;
|
|
||||||
throw("Table doesn't exist")
|
|
||||||
); true.
|
|
||||||
|
|
||||||
|
|
||||||
does_match([], Table, Row) :-
|
|
||||||
Term =.. [Table | Row],
|
Term =.. [Table | Row],
|
||||||
retract(Term),
|
retract(Term),
|
||||||
fail.
|
fail
|
||||||
|
;
|
||||||
|
throw("Table doesn't exist")
|
||||||
|
).
|
||||||
|
|
||||||
|
delete(_, _).
|
||||||
|
|
||||||
|
|
||||||
|
does_match([], _, _) :- !.
|
||||||
|
|
||||||
does_match([Cond|Rest], Table, Row) :-
|
does_match([Cond|Rest], Table, Row) :-
|
||||||
% Extract the operator, field and value from the condition
|
% Extract the operator, field and value from the condition
|
||||||
|
|
Loading…
Reference in New Issue