zsl...@gmail.com
unread,Jun 30, 2015, 10:22:45 AM6/30/15You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I wrote a my custom portray hook for multi-level assocs, but the debugger won't call it because assocs are not ground.
The docs for portray say this:
For each subterm encountered that is not a variable print/1 first calls portray/1 using the term as argument.
I guess this means it's only called for ground terms, right?
Is there a way to force portray on non-ground terms?
I copy my code here, maybe it will be useful for someone. It works fine when directly called.
portray(T):-
is_assoc(T),!, port2(T).
portray(A-T):-
is_assoc(T),!,portray(A),write('-'),port2(T).
portray(T):- write(T).
port2(T):- assoc_to_list(T,L),write('{'),
findall(
E,
(
member(E,L),portray(E),
(
last(L,E) -> true;
write(', ')
)
)
,_
),
write('}').
pce_portray:portray(T):- portray(T).