[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Flatten, question
From: |
Hartmut Lange |
Subject: |
Flatten, question |
Date: |
Thu, 30 Oct 2008 19:13:39 +0100 |
User-agent: |
Thunderbird 2.0.0.17 (Windows/20080914) |
Everybody,
is somebody here who can help me in this small algorithm.
Why do I get
atom_concat/3: Type error: `atomic' expected, found `[g]'
atom_concat/3: Type error: `atomic' expected, found `[e]'
in the line where flatten1(...) is called with the list of a,b,c...
What's wrong with that... hmm? I found it in the Prolog book of Bratko,
excercise 3.11
I am using SWI-Prolog 5.6
Regards,
flatten1([Head|Tail], List) :-
flatten1(Head, FlatHead),
flatten1(Tail, FlatTail),
concat(FlatHead,FlatTail, List).
flatten1([], []).
flatten1(X, [X]).
:- flatten1([a,b,c,e,f,g], List),
write('Flat List:'), write(List).
:- flatten1([a,b,[c,e],f,g], List),
write('Flat List:'), write(List).