Commit dd83b3c6 authored by Thierry Martinez's avatar Thierry Martinez

Current models

parent 584ce8f3
......@@ -9,6 +9,7 @@
get_model_name/2,
set_model_name/1,
list_models/0,
list_current_models/0,
select_model/1,
current_models/1,
single_model/1,
......@@ -22,7 +23,9 @@
item/1,
find_item/1,
all_items/2,
all_ids/2,
list_items/1,
list_ids/1,
delete_item/1,
delete_items/1,
delete/1,
......@@ -207,6 +210,13 @@ list_models :-
list_items([model: top, kind: model]).
list_current_models :-
biocham_command,
doc('lists current models'),
current_models(CurrentModels),
list_ids(CurrentModels).
:- grammar(ref).
......@@ -381,6 +391,7 @@ item(Options) :-
),
item(Id, ModelId, Kind, Item).
find_item(Options) :-
(
item(Options)
......@@ -390,6 +401,7 @@ find_item(Options) :-
throw(error(unknown_item))
).
all_items(Options, Items) :-
findall(
Item,
......@@ -397,6 +409,15 @@ all_items(Options, Items) :-
Items
).
all_ids(Options, Ids) :-
findall(
Id,
item([id: Id | Options]),
Ids
).
optional(Item, List) :-
(
memberchk(Item, List)
......@@ -411,13 +432,19 @@ optional(Item, List) :-
list_items(Options) :-
all_ids(Options, Ids),
list_ids(Ids).
list_ids(Ids) :-
retractall(listed_item(_, _)),
set_counter(list_item_counter, 0),
\+ (
item([item: Item, id: Id | Options]),
count(list_item_counter, Counter),
member(Id, Ids),
\+ (
count(list_item_counter, Counter),
assertz(listed_item(Counter, Id)),
item(Id, _, _, Item),
format('[~d] ~w\n', [Counter, Item])
)
).
......
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