I have searched Prolog Operator expected error questions at stack overflow, however I can't identify the error I am getting :
4:26: Syntax error: Operator expected
% 3.pl compiled 0.00 sec, 3 clauses
The code is simple:
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).
This is really a duplicate of this question: Prolog map procedure that applies predicate to list elements
But I'll bite. You cansimply say, as was suggested:
map( _ , [] , [] ) .
map( G , [X|Xs] , [Y|Ys] ) :-
call(G,X,Y) ,
map(G,Xs,Ys) .