This is my attempt so far. I am not sure what is wrong with this approach. Similar to other languages, the flatten equation
- Checks to see if the list is empty
- Checks to see if the head is empty, then continues with tail
- Checks is the head of original and unflattened list are equal
flatten([],[]).
flatten([X1|PS], [[X1|XS]) :- flatten(PS, [XS]).
flatten(PS, [X1|XS]) :- flatten(A, [X1]), flatten(B, [XS]), append(A,B, PS).
flatten( [PS],PS).