I'm new in turbo prolog.I'm facing a problem in appending nested list. I want the goal like this-
Goal: mega_append([[1,3],[2,4,6],[0]],X)
Output should be X=[1,3,2,4,6,0]
I used the following codes:
domains
list=integer*
predicates
mega_append(list,list)
append(list,list,list)
clauses
mega_append([],[]).
mega_append([H|T],L3):-
mega_append(H,L1),
mega_append(T,L2),
append(L1,L2,L3).
mega_append(X,[X]).
append([],ListB,ListB).
append([X|List1],List2,[X|List3]):-
append(List1,List2,List3).
The program generates an error.It is "illegal variable type in this position." Then it indicates the position of H in the line- mega_append(H,L1). How can I get rid of this problem? Is there any mistake in my program? Please help me.