1
做一个小例子,我想在特定pozition努力学习Prolog的,也弄不清什么是错
domains
element = symbol
list = element*
position = integer
predicates
insert (element, position, list, list) %(input,input,input,output)
clauses
insert (E,_,[],[E]).
insert (E, 1,[H|T],[E|[H|T]]). %(I insert E on the "first" position)
% I get errors how E and T are not bound. I have no idea how to make them bound
insert (E,P,[H|T],[H1|T1]) :-
P > 1,
P1 = P - 1,
insert (E,P1,T,T1).
它不工作插入列表中的符号......但我不知道为什么。那么它有点作品。我希望它向我展示outputList = [NEW_LIST]
而不是每个symbolName=_
然后outputList = [_,_,_,_]
。