I don't know Prolog at all, but still I need to understand what this program does. Compiler shows that there're 2 syntax errors, but the main logic of this program should still be understandable.
domains
value=symbol
level=integer
ltype1=s(value,level)
ltype2=tree(value,ltype2,ltype2); void
list1=ltype1*
predicates
append(list1,list1,list1)
totree(ltype2,integer,list1)
clauses
append([],X,X).
append([X|T],Y,[X|Z]):-append(T,Y,Z).
totree(void,_,[]).
totree(tree(X,Y,Z),N,[s(X,N)|TA]):-
K=N+1,
totree(Y,K,TA1),
totree(Z,K,TA2),
append(TA1,TA2,TA).
goal
totree(
tree(a,tree(b,tree(c,void,void),tree(e,void,void)),tree(d,void,void)),
1,C),
write(C),
totree(W,1,
[s(a,1),s(b,2),s(c,3),s(e,3),s(d,2)]).
domains,predicates,clauses, andgoalare unique to those implementations. You basically have to get rid of thedomainsandpredicatessection.clausesare the predicates that you are trying to define.goalshould either be written as a predicate or called directly. There are other differences in implementations as well. - lurker