row/2, rows/1
This commit is contained in:
parent
2cf01ac3ae
commit
59ea540c45
19
solution.pl
19
solution.pl
|
@ -40,7 +40,13 @@ cols(Table, Cols) :-
|
||||||
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) :-
|
||||||
|
tabl(Table, Cols) ->
|
||||||
|
(
|
||||||
|
length(Cols, L),
|
||||||
|
length(Row, L),
|
||||||
|
apply(Table, Row)
|
||||||
|
); fail.
|
||||||
|
|
||||||
:- dynamic rows/1.
|
:- dynamic rows/1.
|
||||||
/*
|
/*
|
||||||
|
@ -48,7 +54,16 @@ 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
|
||||||
exception.
|
exception.
|
||||||
*/
|
*/
|
||||||
/* rows(Table). */
|
rows(Table) :-
|
||||||
|
\+ tabl(Table, _),
|
||||||
|
throw(table_does_not_exist(Table)),
|
||||||
|
!.
|
||||||
|
|
||||||
|
rows(Table) :-
|
||||||
|
row(Table, Row),
|
||||||
|
writeln(Row),
|
||||||
|
fail.
|
||||||
|
rows(_).
|
||||||
|
|
||||||
:- dynamic insert/2.
|
:- dynamic insert/2.
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue