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).
|
Prints the names of all existing tables, one per line (use writeln/1).
|
||||||
A table name is always an atom.
|
A table name is always an atom.
|
||||||
*/
|
*/
|
||||||
tables.
|
tables :- tabl(X, _), writeln(X).
|
||||||
|
|
||||||
:- dynamic tables/1.
|
:- dynamic tables/1.
|
||||||
/*
|
/*
|
||||||
Unify Tables with a list of the names of all existing tables.
|
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.
|
:- 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).
|
descriptive exception (use throw/1).
|
||||||
All exceptions must have a descriptive error message.
|
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.
|
:- dynamic cols/2.
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue