List is the list of values in leaf nodes of a binary tree and I am trying to figure out how to output just that. This is giving me all the nodes but I need just the leaves
The same solution, not so far from first implementation, can be expressed as:
lea(nil, []). lea(t(X, nil, nil), [X]). lea(t(_, A, B), L) :- lea(A, L1), lea(B, L2), append(L1, L2, L) L \= [].
The last row (L \= []) can be removed (if you accept the possibility of find every solution).
L \= []