This predicate is intended mainly for testing purposes, because portray-transformations are normally performed implicitly by the term output predicates write/1,2, writeln/1,2, print/1,2, display/1,2, printf/2,3 or write_term/2,3.
% Given the program:
:- local portray(s/1, tr_s/2, []).
tr_s(0, 0).
tr_s(s(S), N) :- tr_s(S, N1), N is N1+1.
% Implicit portray transformation by write/1:
?- S = s(s(s(0))), write(S).
3
yes.
% Explicit portray transformation
% Note: no transformation done by writeq/1
?- S = s(s(s(0))), writeq(S), portray_term(S, P, term), writeq(P).
s(s(s(0)))
3
yes.