[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: predicate_property help.
From: |
Paulo Moura |
Subject: |
Re: predicate_property help. |
Date: |
Tue, 2 Oct 2007 20:37:03 +0100 |
On 2007/10/02, at 15:20, Amine Marref wrote:
The above code works with Sicstus for instance. However, GNU Prolog
needs A to be a predicate indicator e.g. length/2 and not a goal.
True.
so:
| ?- predicate_property(length/2, built_in).
yes
| ?- predicate_property(length([a,b],2), built_in).
uncaught exception: error(type_error(predicate_indicator,length
([a,b],2)),predicate_property/2)
My question is then: how do I go from the goal length([a,b],2) to
the predicate indicator length/2?
The best I could do was:
| ?- functor(length([a,b],2), Functor, Arity), atom_concat
(Functor,/,Temp), number_atom(Arity, Arity1), atom_concat(Temp,
Arity1, Predicate_Indicator).
Arity = 2
Arity1 = '2'
Functor = length
Predicate_Indicator = 'length/2'
Temp = 'length/'
yes
However, 'length/2' does not work as first argument to
predicate_property.
Of course not, 'length/2' is an atom. Try:
| ?- functor(length([a,b],2), Functor, Arity), predicate_property
(Functor/Arity, built_in).
All the best,
Paulo
-----------------------------------------------------------------
Paulo Jorge Lopes de Moura
Dep. of Computer Science, University of Beira Interior
6201-001 Covilhã, Portugal
Office 4.3 Ext. 3257
Phone: +351 275319891 Fax: +351 275319899
Email: <mailto:address@hidden>
Home page: <http://www.di.ubi.pt/~pmoura>
Research: <http://logtalk.org/>
-----------------------------------------------------------------