Commit 920b1d36 authored by Thierry Martinez's avatar Thierry Martinez

ploum

parents 742b83bc 11cbe4b0
......@@ -298,6 +298,8 @@ generate_body(Doc, Type) :-
\+ (
toc(Item),
\+ (
print(Item),
nl,
generate_body_item(Item, Doc, Type)
)
).
......
......@@ -39,7 +39,8 @@
begin_command/0,
get_selection/2,
set_selection/2,
at_delete/2
at_delete/2,
get_parent/2
]
).
......@@ -858,3 +859,7 @@ set_selection(SelectionName, IdsOrOptions) :-
at_delete(Id, Goal) :-
assertz(at_delete_goal(Id, Goal)).
get_parent(Id, ParentId) :-
item(Id, ParentId, _, _).
......@@ -39,6 +39,8 @@ make_ode_system :-
solve(Time) :-
print(hello),
nl,
gather_headers(Headers),
gather_equations(Equations),
gather_initial_values(InitialValues),
......@@ -56,7 +58,11 @@ solve(Time) :-
time_final: Time
],
solve(Options, Table),
add_table('numerical_simulation', Table).
print(here),
nl,
add_table('numerical_simulation', Table),
print(there),
nl.
gather_headers(Headers) :-
......
......@@ -14,6 +14,7 @@ plot :-
biocham_command,
doc('plots the current trace.'),
get_plot_driver(Driver),
print(here), nl,
Driver.
......
......@@ -7,10 +7,12 @@
rename_table/1,
list_tables/0,
delete_table/1,
list_rows/0,
list_columns/0,
column/1,
delete_column/1,
rename_column/2,
delete_row/1,
add_table/2,
get_table_data/1,
get_current_table/1,
......@@ -112,6 +114,13 @@ delete_table(TableSet) :-
).
list_rows :-
biocham_command,
doc('lists the rows of the current table.'),
get_current_table(Id),
list_items([parent: Id, kind: row]).
list_columns :-
biocham_command,
doc('lists the column names of the current table.'),
......@@ -131,7 +140,7 @@ column(Name) :-
delete_column(Columns) :-
biocham_command(*),
type(Column, '*'(column)),
type(Columns, '*'(column)),
doc('deletes the given columns from the current table.'),
get_current_table(Id),
\+ (
......@@ -144,7 +153,6 @@ delete_column(Columns) :-
;
find_item([parent: Id, kind: column, item: Column, id: ColumnId])
),
print(ColumnId), nl,
delete_item(ColumnId)
)
).
......@@ -161,13 +169,27 @@ rename_column(Column, Name) :-
->
ColumnIndex = Column
;
find_item([parent: Id, kind: column, item: Column]),
get_annotation(Column, index, ColumnIndex)
find_item([parent: Id, kind: column, item: Column, id: ColumnId]),
get_annotation(ColumnId, index, ColumnIndex)
),
delete_items([parent: Id, kind: column, key: ColumnIndex]),
declare_column(Id, ColumnIndex, Name).
delete_row(Rows) :-
biocham_command(*),
type(Rows, '*'(number)),
doc('deletes the given rows from the current table.'),
get_current_table(Id),
\+ (
member(Row, Rows),
\+ (
find_item([parent: Id, kind: column, key: Row, id: RowId]),
delete_item(RowId)
)
).
:- devdoc('\\section{Public API}').
......@@ -199,13 +221,36 @@ add_table(Name, Table) :-
),
Data = Table
),
set_annotation(Id, data, Data),
\+ (
nth0(RowIndex, Data, Row),
\+ (
add_item([parent: Id, kind: row, key: RowIndex, item: Row, id: RowId]),
set_annotation(RowId, index, RowIndex),
at_delete(RowId, tables:perform_row_delete(RowId))
)
),
set_current_table(Id).
get_table_data(Data) :-
get_current_table(Id),
get_annotation(Id, data, Data).
set_counter(row, 0),
findall(
Row,
(
repeat,
(
count(row, RowIndex),
item([parent:Id, kind: row, key: RowIndex, item: Row])
->
true
;
!,
fail
)
),
Data
).
get_column_name(Index, Name) :-
......@@ -230,27 +275,46 @@ declare_column(Id, ColumnIndex, Name) :-
[parent: Id, kind: column, key: ColumnIndex, item: Name, id: ColumnId]
),
set_annotation(ColumnId, index, ColumnIndex),
at_delete(ColumnId, tables:perform_column_delete(Id, ColumnIndex)).
at_delete(ColumnId, tables:perform_column_delete(ColumnId)).
perform_column_delete(Id, ColumnIndex) :-
(
get_annotation(Id, data, Data)
->
print(ColumnIndex), nl,
findall(
NewRow,
(
member(Row, Data),
Row =.. [row, RowItems],
nth0(ColumnIndex, RowItems, _Deleted, NewRowItems),
NewRow =.. [row, NewRowItems]
),
NewData
),
set_annotation(Id, data, NewData)
;
true
perform_column_delete(ColumnId) :-
get_parent(ColumnId, TableId),
get_annotation(ColumnId, index, ColumnIndex),
\+ (
item([parent:TableId, kind: row, item: Row, id: RowId]),
\+ (
get_annotation(RowId, index, RowIndex),
Row =.. [row | RowItems],
nth0(ColumnIndex, RowItems, _Deleted, NewRowItems),
NewRow =.. [row | NewRowItems],
replace_item(RowId, row, RowIndex, NewRow)
)
),
\+ (
item([parent:TableId, kind: column, item: Column, id: ColumnId]),
get_annotation(ColumnId, index, ColumnIndex),
Row =.. [row | RowItems],
nth0(ColumnIndex, RowItems, _Deleted, NewRowItems),
NewRow =.. [row | NewRowItems],
replace_item(RowId, row, RowIndex, NewRow)
\+ (
)
).
perform_row_delete(RowId) :-
get_parent(RowId, TableId),
get_annotation(RowId, index, RowIndex),
\+ (
item([parent:TableId, kind: row, item: Row0, id: RowId0]),
get_annotation(RowId0, index, RowIndex0),
RowIndex0 > RowIndex,
\+ (
replace_item(RowId0, row, RowIndex0, Row0),
RowIndex1 is RowIndex0 - 1,
set_annotation(RowId0, index, RowIndex1)
)
).
......
......@@ -7,15 +7,27 @@ test(
[true(Tables == [table])]
) :-
clear_model,
add_table(table, [row(50, 50)]),
add_table(table, [row(1, 2)]),
all_items([kind: table], Tables).
test(
'get_table_data',
[true(Data == [row(50, 50)])]
[true(Data == [row(1, 2)])]
) :-
clear_model,
add_table(table, [row(50, 50)]),
add_table(table, [row(1, 2)]),
get_table_data(Data).
test(
'delete_column',
[true(Data == [row(1, 3), row(4, 6)])]
) :-
clear_model,
add_table(table, [row(1, 2, 3), row(4, 5, 6)]),
print(here),
command(delete_column(1)),
print(there),
nl,
get_table_data(Data).
test(
......
......@@ -112,9 +112,7 @@ command(Command) :-
Command0 = Command
;
between(1, Arity, Arity0),
print(Functor/Arity0),
predicate_info(Functor/Arity0, ArgumentTypes, variantargs, _),
print(variantargs)
predicate_info(Functor/Arity0, ArgumentTypes, variantargs, _)
->
Command =.. [Functor | Arguments],
PrefixLength is Arity0 - 1,
......
......@@ -27,7 +27,6 @@ predicate_info((Head :- Body), ArgumentTypes, BiochamCommand, Doc) :-
predicate_info(Functor/Arity, ArgumentTypes, BiochamCommand, Doc) :-
functor(Head, Functor, Arity),
once(clause(Head, Body)),
print(found),
predicate_info((Head :- Body), ArgumentTypes, BiochamCommand, Doc).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment