I\'ve only been working with Prolog for a couple days. I understand some things but this is really confusing me.
I\'m suppose to write a function that takes a list
Without any other predicate, with tail-recursion only.
flatten([[X|S]|T], F) :- flatten([X|[S|T]], F). flatten([[]|S], F) :- flatten(S, F). flatten([X|S], [X|T]) :- \+(X = []), \+(X = [_|_]), flatten(S, T). flatten([], []).