General
Material
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 5

Solution

flatten_dcg([]) --> [].

flatten_dcg([H|T]) --> flatten_dcg(H), flatten_dcg(T).

flatten_dcg(X) --> {X\=[]}, {X\=[_|_]}, [X].
    

Back to the exercise.