I'm a Prolog newbie, so please excuse me if this is a lame question.
Is it possible to use a variable as a functor? I'm doing some meta-
programming, and it would be helpful to be able to call a predicate
whose name is unknown at compile time.
I've already looked in many places, but found no answer.
Thanks in advance.
A. Rubio
> Hi,
>
> I'm a Prolog newbie, so please excuse me if this is a lame question.
>
> Is it possible to use a variable as a functor?
Have a look at 'call()'
If you are using SWI-Prolog you can get a lot of help by typing
help(call). % and apropos(meta).
I'm doing some meta-
> programming, and it would be helpful to be able to call a predicate
> whose name is unknown at compile time.
If 'Variable' is a goal, then you can simply invoke it as
Variable. % The same same as call(Variable).
You might also find '=..' helpful.
>
> I've already looked in many places, but found no answer.
>
I find SWI Prolog's online help very useful. You can download it from
http://www.swi-prolog.org/. Install it then search the documentation by
entering
help.
Thanks a lot, I'll have a look at those.