Prolog 运算符预期错误
Prolog Operator Expected Error
我搜索了 Prolog Operator expected error questions at stack overflow,但是我无法确定我遇到的错误:
4:26: Syntax error: Operator expected
% 3.pl compiled 0.00 sec, 3 clauses
代码很简单:
inc(N,R) :-
R is N + 1. % Simple code to increment a number.
mapcar( F , [] , [] ). % Base case
mapcar( F , [H|T] ,[RH|RT] ) :- % Increment head and put it in Result Head and Recurse for Tail
F(H,RH),
mapcar(F,T,RT).
这确实是这个问题的重复:Prolog map procedure that applies predicate to list elements
但我会咬人。你可以像建议的那样简单地说:
map( _ , [] , [] ) .
map( G , [X|Xs] , [Y|Ys] ) :-
call(G,X,Y) ,
map(G,Xs,Ys) .
我搜索了 Prolog Operator expected error questions at stack overflow,但是我无法确定我遇到的错误:
4:26: Syntax error: Operator expected
% 3.pl compiled 0.00 sec, 3 clauses
代码很简单:
inc(N,R) :-
R is N + 1. % Simple code to increment a number.
mapcar( F , [] , [] ). % Base case
mapcar( F , [H|T] ,[RH|RT] ) :- % Increment head and put it in Result Head and Recurse for Tail
F(H,RH),
mapcar(F,T,RT).
这确实是这个问题的重复:Prolog map procedure that applies predicate to list elements
但我会咬人。你可以像建议的那样简单地说:
map( _ , [] , [] ) .
map( G , [X|Xs] , [Y|Ys] ) :-
call(G,X,Y) ,
map(G,Xs,Ys) .