Move deletion logic to delete/2
This commit is contained in:
parent
d5351f3dee
commit
eeaba5ee46
14
solution.pl
14
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
|
||||
|
|
Loading…
Reference in New Issue