% Invisit of a binary tree

% Representation of binary trees: as terms of the form
% - emptybt (base case, empty binary tree)
% - consbt(N,T1,T2)  tree which has root N and left and right 
%                    subtrees T1 and T2 respectively.

% invisit(T,L) holds iff L is the list of nodes obtained 
%                        from the invisit of T

invisit(emptybt, []).
invisit(consbt(N,T1,T2), L) :- invisit(T1,L1), invisit(T2,L2), append(L1,[N|L2],L).
                               