Re: how to get predicats from facts?
- From: corps <liyusheng@xxxxxxxxx>
- Date: Mon, 24 Dec 2007 07:02:21 -0800 (PST)
On Dec 24, 6:30 pm, Jan Wielemaker <j...@xxxxxxxxxxxxxxxxxxx> wrote:
On 2007-12-24, Martin Riener <martin.rie...@xxxxxxxxx> wrote:
corps wrote:
predicate_solutions(Name/Arity,S) :-
length(L,Arity),
append([Name],L,P),
Pred =.. P,
findall(L, Pred, S).
I think this is a bit better style:
predicate_solutions(Name/Arity,S) :-
length(Args,Arity),
Goal =.. [Name|Args],
findall(Args, Goal, S).
But it is very unlikely you actually want a list of lists. This makes it
a bit dubious whether you ever want something this general.
Cheers --- Jan
Please take into account that this is what came to my mind first - there
is no check, if the predcate exists and it is certainly not the most
elegant solution.
hth, Martin- Hide quoted text -
- Show quoted text -
I tried the solutions and it seems they are not what I mean. Name
needs to be a predicate. But what I want is to find out all predicates
that has tom defined. so given tom, it should return [person, cat].
.
- Follow-Ups:
- Re: how to get predicats from facts?
- From: bart demoen
- Re: how to get predicats from facts?
- References:
- how to get predicats from facts?
- From: corps
- Re: how to get predicats from facts?
- From: Martin Riener
- Re: how to get predicats from facts?
- From: Jan Wielemaker
- how to get predicats from facts?
- Prev by Date: Re: how to get predicats from facts?
- Next by Date: Re: how to get predicats from facts?
- Previous by thread: Re: how to get predicats from facts?
- Next by thread: Re: how to get predicats from facts?
- Index(es):
Relevant Pages
|
|