:- module(flatten,[flatten/2]).

:- [prolog_detect].

:- prolog_detect:prolog(Prolog),
	(	(Prolog=quintus,
		use_module(library(lists))
		);
		(Prolog=sicstus,
		use_module(library(lists))
		);
		(Prolog=pfdm,
		use_module(library(lists))
		);
		format("*** NOTE: flatten/2 is built-in in SWI & ECLiPSe~n",[])
	).

flatten([],[]).
flatten([H|T],F)        :-
        is_list(H),
        !,
        flatten(H,Fh),
        flatten(T,Ft),
        append(Fh,Ft,F).

flatten([H|T],[H|F])    :-
        flatten(T,F).

