/* kb10.pl */ prn_list_str(X) :- pp(X,3). pp(X,I) :- atomic(X), I1 is I - 1, tab(I1), write(\), write_branch(2), write(X), nl, !. pp([H|T],I) :- tab(I), write(\), write_branch(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(0) :- !. write_branch(N) :- put(45), N1 is N-1, write_branch(N1). % string_length(A,N) :- name(A,List), length(List,N). % length([],0). % length([K|R],N) :- length(R,M), % N is M+1.