First answers
This commit is contained in:
parent
39593bc48b
commit
dc73df33b0
|
@ -3,13 +3,13 @@
|
|||
Prints the names of all existing tables, one per line (use writeln/1).
|
||||
A table name is always an atom.
|
||||
*/
|
||||
tables.
|
||||
tables :- tabl(X, _), writeln(X).
|
||||
|
||||
:- dynamic tables/1.
|
||||
/*
|
||||
Unify Tables with a list of the names of all existing tables.
|
||||
*/
|
||||
tables(Tables).
|
||||
tables(Tables) :- findall(X, tabl(X, _), Tables).
|
||||
|
||||
:- dynamic create_table/2.
|
||||
/*
|
||||
|
@ -20,7 +20,9 @@ If a table with the given name already exists, the predicate must throw a
|
|||
descriptive exception (use throw/1).
|
||||
All exceptions must have a descriptive error message.
|
||||
*/
|
||||
create_table(Table, Cols).
|
||||
create_table(Table, Cols) :-
|
||||
(tabl(Table, _) -> throw("Table already exists"));
|
||||
assertz(tabl(Table, Cols)).
|
||||
|
||||
:- dynamic cols/2.
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue