From fed10a2a2559cffbd7cfb8d74f04d1108b04974a Mon Sep 17 00:00:00 2001 From: Brieuc Dubois Date: Sun, 10 Mar 2024 14:19:45 +0100 Subject: [PATCH] drop/1, delete/1 --- solution.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/solution.pl b/solution.pl index b6c243c..f73b64f 100644 --- a/solution.pl +++ b/solution.pl @@ -81,7 +81,11 @@ and signature later on. If the given table does not exist, the predicate must throw a descriptive exception. */ -/* drop(Table). */ +drop(Table) :- + (tabl(Table, _) -> + delete(Table), retract(tabl(Table, _)); + throw("Table doesn't exist") + ). :- dynamic delete/1. /* @@ -91,7 +95,11 @@ more rows. If the given table does not exist, the predicate must throw a descriptive exception. */ -/* delete(Table). */ +delete(Table) :- + (tabl(Table, _) -> + tabl(Table, C), length(C, L), call(abolish, Table, L); + throw("Table doesn't exist") + ). :- dynamic delete/2. /*