Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using a Variable as a Functor

1 view
Skip to first unread message

arcadio

unread,
May 10, 2008, 11:52:33 AM5/10/08
to
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? 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

Louis

unread,
May 10, 2008, 12:50:26 PM5/10/08
to
On Sat, 10 May 2008 08:52:33 -0700, arcadio wrote:

> 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.

arcadio

unread,
May 10, 2008, 1:07:44 PM5/10/08
to

Thanks a lot, I'll have a look at those.

0 new messages