distribution is now named through its structure, not just the main functor.

This commit is contained in:
Vitor Santos Costa 2008-10-29 20:52:56 +00:00
parent 922424abd0
commit d1db0d68ea

View File

@ -90,12 +90,10 @@ dist(V, Id, Key, Parents) :-
var(Key), !, var(Key), !,
when(Key, dist(V, Id, Key, Parents)). when(Key, dist(V, Id, Key, Parents)).
dist(p(Type, CPT), Id, Key, FParents) :- dist(p(Type, CPT), Id, Key, FParents) :-
functor(Key, Na, Ar), copy_structure(Key, Key0),
functor(Key0, Na, Ar),
distribution(Type, CPT, Id, Key0, [], FParents). distribution(Type, CPT, Id, Key0, [], FParents).
dist(p(Type, CPT, Parents), Id, Key, FParents) :- dist(p(Type, CPT, Parents), Id, Key, FParents) :-
functor(Key, Na, Ar), copy_structure(Key, Key0),
functor(Key0, Na, Ar),
distribution(Type, CPT, Id, Key0, Parents, FParents). distribution(Type, CPT, Id, Key0, Parents, FParents).
dist_unbound(V, ground(V)) :- dist_unbound(V, ground(V)) :-
@ -238,3 +236,15 @@ dist_new_table(Id, NewMat) :-
fail. fail.
dist_new_table(_, _). dist_new_table(_, _).
copy_structure(V, V) :- var(V), !.
copy_structure(V, _) :- primitive(V), !.
copy_structure(Key, Key0) :-
Key =.. [A|LKey],
copy_Lstructure(LKey, LKey0),
Key0 =.. [A|LKey0].
copy_Lstructure([], []).
copy_Lstructure([H|LKey], [NH|LKey0]) :-
copy_structure(H, NH),
copy_Lstructure(LKey, LKey0).