%%% A utility program to draw a simplified horizontal tree structure %%% %%% --- used in combination with a chart parser "chart.pl" %%% tree_ls(X) :- pp(X,3). pp(X,I) :- atomic(X),!, I1 is I - 1, tab(I1),write('|'), write_branch_h(2), write(X). pp([H|T],I) :- I0 is I-1, tab(I0), write('|'), write_branch_h(2), write(H), string_length(H,N), I1 is I+N+3,nl,ppx(T,I1). ppx([],_). ppx([H|T],I) :- atomic(H),!,pp([H],I),ppx(T,I). ppx([H|T],I) :- not(atomic(H)),!,pp(H,I),ppx(T,I). write_branch_h(0) :- !. write_branch_h(N) :- put(45), N1 is N-1, write_branch_h(N1).