logo       

Re: How to counter number arguments in a fact ?: msg#01568

Subject: Re: How to counter number arguments in a fact ?
----- Original Message -----
From: "Sombat Khruathong" <lli_unp@xxxxxxxx>
To: "swi prolog" <prolog@xxxxxxxxxxxxxx>
Sent: Thursday, December 15, 2005 7:13 AM
Subject: [SWIPL] How to counter number arguments in a fact ?

Sombat,

> Dear All,
> Would you please to help me to find a way to count the
> number of arguments in a clause ?
>
> For example, if I have a predicate like
>     "noun(gender,Number,Sens1,Sens2,_,love)",
> how can I ask prolog for an answer indicating the number
> of arguments of noun/6 ?
>

Hopefully I've correctly understood your question. You could try:

    functor(noun(gender,Number,Sens1,Sens2,_,love), _, Arity) ...

or:

    functor(noun(_,_,_,_,_,_), _, Arity) ...

and the variable 'Arity' will be instantiated to the number of arguments in
the term, 'noun'.

Check out section 4.20 'Analysing and Constructing Terms' in the SWI Help
for more details.

Cheers,

Anthony Borla




<Prev in Thread] Current Thread [Next in Thread>