row/2, rows/1

This commit is contained in:
Brieuc Dubois 2024-03-13 09:49:08 +01:00
parent 2cf01ac3ae
commit 59ea540c45
1 changed files with 17 additions and 2 deletions

View File

@ -40,7 +40,13 @@ cols(Table, Cols) :-
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.
*/
/* row(Table, Row). */
row(Table, Row) :-
tabl(Table, Cols) ->
(
length(Cols, L),
length(Row, L),
apply(Table, Row)
); fail.
:- 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
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.
/*