i am using ancient turbo prolog . and continously facing error in following code :- mis-spelling or not declared predicate
domains
A,B,C = symbol
N,P = integer
predicates
tower(integer,symbol,symbol,symbol,integer)
go
clauses
go :- clearwindow,
write("enter value of N (For Transfering from A To B)"),
readint开发者_运维知识库(N),
tower(N,'a','b','c',N).
tower(N,A,B,C,P):-
N > 1,
P is N-1
tower(P,A,C,B,P),
write([move , A,B]),nl,
tower(P,C,B,A,P).
tower(0,_,_,_):- !.
You're missing a comma after P is N-1
.
Also, your domain declarations don't make sense. The syntax is not for associating variables with domains (symbol and integer are predefined for you), but rather for creating specialized domains from the predefined ones. It doesn't appear that your program needs any domain declarations.
Tutorials for domains, etc. in Turbo Prolog are rather scarce online, due to the passage of time, so your best bet (if you lack original documentation) may be to look at one of Visual Prolog tutorials.
Try replacing is
with =
[Like: P = N-1
]
精彩评论