Commit abedb06f authored by Thierry Martinez's avatar Thierry Martinez

Correct patch_inputs and influence pretty-printer

parent 8e94a489
......@@ -10,7 +10,8 @@
check_influence_model/0,
list_model_influences/0,
influence/6,
compute_ode_for_influence_model/0
compute_ode_for_influence_model/0,
print_influence/2
]
).
......@@ -148,6 +149,37 @@ compute_ode_for_influence_model :-
).
print_influence(_Id, Item) :-
(
Item = (Force for BasicInfluence)
->
format('~w for ', [Force])
;
BasicInfluence = Item
),
(
BasicInfluence = (Inputs -> Output)
->
Arrow = '->'
;
BasicInfluence = (Inputs -< Output)
->
Arrow = '-<'
),
(
Inputs = (PositiveInputs / NegativeInputs)
->
format('~w / ~w', [PositiveInputs, NegativeInputs])
;
Inputs = (/ NegativeInputs)
->
format('/ ~w', [NegativeInputs])
;
write(Inputs)
),
format(' ~w ~w', [Arrow, Output]).
:- devdoc('\\section{Private predicates}').
......
......@@ -85,17 +85,11 @@ influence_predicate(_ -> _).
influence_predicate(_ -< _).
patch_inputs((Inputs0, Inputs1), Inputs) :-
!,
patch_inputs(Inputs0, Inputs1, Inputs).
patch_inputs(Inputs, Inputs).
patch_inputs(Inputs0, (Inputs1, Inputs2), Inputs) :-
patch_inputs((Inputs0, Inputs1), Inputs2, Inputs).
patch_inputs((A / B, C), A / (B, C)) :-
!.
patch_inputs(Inputs0, Inputs1 / Inputs2, (Inputs0, Inputs1) / Inputs2) :-
patch_inputs((A, B), (A, B0) / B1) :-
patch_inputs(B, B0 / B1),
!.
patch_inputs(Inputs0, Inputs1, (Inputs0, Inputs1)).
patch_inputs(Inputs, Inputs).
......@@ -38,6 +38,7 @@
list_items/1,
list_ids/1,
list_ids/2,
print_item/1,
delete_item/1,
delete_items/1,
add_dependency/2,
......@@ -478,6 +479,19 @@ list_ids(Options, Ids) :-
list_ids_aux(Options, Ids).
print_item(Id) :-
item(Id, _Parent, Kind, Item),
(
atom_concat('print_', Kind, F),
G =.. [F, Id, Item],
predicate_property(G, visible)
->
G
;
write(Item)
).
delete_item(Options) :-
list(Options),
!,
......@@ -691,7 +705,6 @@ list_ids_aux(Options, Ids) :-
\+ (
member(Id, Ids),
\+ (
item(Id, _, _, Item),
indent(Indent),
(
selection(_, _, Id)
......@@ -709,7 +722,9 @@ list_ids_aux(Options, Ids) :-
assertz(listed_item(Counter, Id)),
format('[~d]', [Counter])
),
format('~a~w\n', [Selected, Item]),
write(Selected),
print_item(Id),
nl,
(
Recursive = yes
->
......
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