I have this arbitrary function that I need to call many times with different variables. btw, this is SWI-Prolog
perform(V1,V2,V3,Function,Result):-
%
% do little stuf.
%
Function(Arg1,Arg2,Result).
This gives a syntax error.
But passing a function as a variable without adding arguments works fine as in the following code:
perform(Function):-
Function.
sayHello:-
write('hello').
:-perform(sayHello).
So how to add arguments to a variable function?
Specifically in SWI-Prolog you can use
call
. Quoting the manual:where the plus indicates that the
argument must be fully instantiated to a term that satisfies the required argument type
, and the colon indicates that theagument is a meta-argument
(this also implies "+").