
file_search_path(semwalker, '/home/sandro/semwalker').
:- ensure_loaded(semwalker(qtest_header)).

%%
%%  flatten(+Tree, ?List)
%%
%%  Turn a tree struction into an in-order list of the leaves
%%

flatten([], []).
flatten(L, FL) :-
	(  L = [X | Xs]
	->  flatten(X, L1),
	    flatten(Xs, L2),
	    append(L1, L2, FL)
	;   FL = [L]
	).

qtest :-
	flatten([a,b,c], [a,b,c]).

qtest :-
	flatten([a,b,[c,[d,e]]], [a,b,c,d,e]).

qtest :-
	flatten([[[a]]], [a]).

qtest :-
	flatten([[[a, [[[b]]]]]], [a,b]).

