added . to predicate declarations
This commit is contained in:
parent
721d974931
commit
d2cebdef6d
27
solution.pl
27
solution.pl
|
@ -1,16 +1,17 @@
|
||||||
|
:- dynamic tables/0.
|
||||||
/*
|
/*
|
||||||
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.
|
||||||
|
|
||||||
:- 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).
|
||||||
|
|
||||||
:- dynamic table/2
|
:- dynamic table/2.
|
||||||
/*
|
/*
|
||||||
When this predicate is executed, the effect will be the creation of a new
|
When this predicate is executed, the effect will be the creation of a new
|
||||||
table with the specified list of column names (order matters!).
|
table with the specified list of column names (order matters!).
|
||||||
|
@ -21,7 +22,7 @@ All exceptions must have a descriptive error message.
|
||||||
*/
|
*/
|
||||||
create table(Table, Cols).
|
create table(Table, Cols).
|
||||||
|
|
||||||
:- dynamic cols/2
|
:- dynamic cols/2.
|
||||||
/*
|
/*
|
||||||
Unifies Cols with the list of columns for the specified table (in the same
|
Unifies Cols with the list of columns for the specified table (in the same
|
||||||
order as they were supplied to create table/2).
|
order as they were supplied to create table/2).
|
||||||
|
@ -30,14 +31,14 @@ exception (use throw/1).
|
||||||
*/
|
*/
|
||||||
cols(Table, Cols).
|
cols(Table, Cols).
|
||||||
|
|
||||||
:- dynamic row/2
|
:- dynamic row/2.
|
||||||
/*
|
/*
|
||||||
Unifies Row, one result at a time, with each row in the given Table.
|
Unifies Row, one result at a time, with each row in the given Table.
|
||||||
If the given table does not exist, the predicate should fail.
|
If the given table does not exist, the predicate should fail.
|
||||||
*/
|
*/
|
||||||
row(Table, Row).
|
row(Table, Row).
|
||||||
|
|
||||||
:- dynamic rows/1
|
:- dynamic rows/1.
|
||||||
/*
|
/*
|
||||||
Displays all rows in the given table, one per line (use writeln/1).
|
Displays all rows in the given table, one per line (use writeln/1).
|
||||||
If the given table does not exist, the predicate must throw a descriptive
|
If the given table does not exist, the predicate must throw a descriptive
|
||||||
|
@ -45,7 +46,7 @@ exception.
|
||||||
*/
|
*/
|
||||||
rows(Table).
|
rows(Table).
|
||||||
|
|
||||||
:- dynamic insert/2
|
:- dynamic insert/2.
|
||||||
/*
|
/*
|
||||||
When this predicate is executed, the effect will be the addition of a given
|
When this predicate is executed, the effect will be the addition of a given
|
||||||
row in the given table. The given row is a list of values for each of the
|
row in the given table. The given row is a list of values for each of the
|
||||||
|
@ -58,7 +59,7 @@ the table, the predicate must throw a descriptive exception.
|
||||||
*/
|
*/
|
||||||
insert(Table, Row).
|
insert(Table, Row).
|
||||||
|
|
||||||
:- dynamic drop/1
|
:- dynamic drop/1.
|
||||||
/*
|
/*
|
||||||
When this predicate is executed, the effect will be the deletion of the given
|
When this predicate is executed, the effect will be the deletion of the given
|
||||||
table.
|
table.
|
||||||
|
@ -70,7 +71,7 @@ exception.
|
||||||
*/
|
*/
|
||||||
drop(Table).
|
drop(Table).
|
||||||
|
|
||||||
:- dynamic delete/1
|
:- dynamic delete/1.
|
||||||
/*
|
/*
|
||||||
When this predicate is executed, the effect will be the deletion of all rows
|
When this predicate is executed, the effect will be the deletion of all rows
|
||||||
in the given table. The table itself should still exist after, but with no
|
in the given table. The table itself should still exist after, but with no
|
||||||
|
@ -80,7 +81,7 @@ exception.
|
||||||
*/
|
*/
|
||||||
delete(Table).
|
delete(Table).
|
||||||
|
|
||||||
:- dynamic delete/2
|
:- dynamic delete/2.
|
||||||
/*
|
/*
|
||||||
When this predicate is executed, the effect will be the deletion of all rows
|
When this predicate is executed, the effect will be the deletion of all rows
|
||||||
from the given table that match all of the given conditions. The table
|
from the given table that match all of the given conditions. The table
|
||||||
|
@ -94,7 +95,7 @@ prompt, but which may include selectors. Selectors are terms of the form
|
||||||
*/
|
*/
|
||||||
delete(Table, Conds).
|
delete(Table, Conds).
|
||||||
|
|
||||||
:- dynamic selec/4
|
:- dynamic selec/4.
|
||||||
/*
|
/*
|
||||||
Note that the name of this predicate is selec (without t) for the simple
|
Note that the name of this predicate is selec (without t) for the simple
|
||||||
reason that select/4 is already a built-in Prolog predicate.
|
reason that select/4 is already a built-in Prolog predicate.
|
||||||
|
@ -126,14 +127,14 @@ returns: Projections = [[0, "Jeffrey"], [1, "Lorena"], [2, "Joseph"], ...
|
||||||
*/
|
*/
|
||||||
selec(Table, Selectors, Conds, Projection)
|
selec(Table, Selectors, Conds, Projection)
|
||||||
|
|
||||||
:- dynamic selec/3
|
:- dynamic selec/3.
|
||||||
/*
|
/*
|
||||||
Simplified variant of the selec/4 predicate when there are no conditions
|
Simplified variant of the selec/4 predicate when there are no conditions
|
||||||
to be checked.
|
to be checked.
|
||||||
*/
|
*/
|
||||||
selec(TableOrTables, Selectors, Projection)
|
selec(TableOrTables, Selectors, Projection)
|
||||||
|
|
||||||
:- dynamic query/2
|
:- dynamic query/2.
|
||||||
/*
|
/*
|
||||||
where Query is a string whose syntax is defined by the following grammar:
|
where Query is a string whose syntax is defined by the following grammar:
|
||||||
⟨query⟩ ::= ⟨select⟩ | ⟨insert ⟩
|
⟨query⟩ ::= ⟨select⟩ | ⟨insert ⟩
|
||||||
|
@ -181,7 +182,7 @@ success, and if query/2 is used the Result parameter can be ignored.
|
||||||
*/
|
*/
|
||||||
query(Query, Result)
|
query(Query, Result)
|
||||||
|
|
||||||
:- dynamic query/1
|
:- dynamic query/1.
|
||||||
/*
|
/*
|
||||||
cf. query/2
|
cf. query/2
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue