0

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). 
false
  • 10,264
  • 13
  • 101
  • 209
ed bale
  • 59
  • 1
  • 9

1 Answers1

1

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) .
Community
  • 1
  • 1
Nicholas Carey
  • 71,308
  • 16
  • 93
  • 135