The definition of this Prolog library predicate is:
flatten(List, Flat) :- flatten_aux(List, Flat, []). flatten_aux([], Res, Cont) :- -?-> !, Res = Cont. flatten_aux([Head|Tail], Res, Cont) :- -?-> !, flatten_aux(Head, Res, Cont1), flatten_aux(Tail, Cont1, Cont). flatten_aux(Term, [Term|Cont], Cont).This predicate does not perform any type testing functions.
Since ECLiPSe 7.0, arrays are treated like lists, and also flattened.
Success:
[eclipse]: flatten([[1,2,[3,4],5],6,[7]], L).
L = [1, 2, 3, 4, 5, 6, 7]
yes.
[eclipse]: flatten([1,2,3], L).
L = [1, 2, 3]
yes.
[eclipse]: flatten(a, L).
L = [a]
yes.
Fail:
[eclipse]: flatten([1,[3],2], [1,2,3]).
no.