Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Portray assoc in the debugger (SWI)

8 views
Skip to first unread message

zsl...@gmail.com

unread,
Jun 30, 2015, 10:22:45 AM6/30/15
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).
0 new messages