insert/2
This commit is contained in:
parent
56e393f049
commit
4ec8cba12b
10
solution.pl
10
solution.pl
|
@ -61,7 +61,15 @@ exception.
|
|||
If the row does not have as many elements as the number of columns in
|
||||
the table, the predicate must throw a descriptive exception.
|
||||
*/
|
||||
/* insert(Table, Row). */
|
||||
insert(Table, Row) :-
|
||||
(tabl(Table, Cols) ->
|
||||
(length(Row, L1), length(Cols, L2), L1 =:= L2 ->
|
||||
Term =.. [Table | Row],
|
||||
assertz(Term);
|
||||
throw("Row doesn't have as many elements as the number of columns in the table")
|
||||
);
|
||||
throw("Table doesn't exist")
|
||||
).
|
||||
|
||||
:- dynamic drop/1.
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue