Re: how to get predicats from facts?



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



Relevant Pages

  • FYI: The Off-List of the Quitlist
    ... Tom Westbrook ...tomAS3twestbrook.com ... Mark ..mark.weatherillAS3btinternet.com ... Steve ...steve.cooperAS3freeuk.com ...
    (alt.support.stop-smoking)
  • AS3 Quit List *OFFLIST* as of September 21, 2007
    ... Tom Westbrook ...tomAS3twestbrook.com ... Mark ..mark.weatherillAS3btinternet.com ... Steve ...steve.cooperAS3freeuk.com ... You see...it does pay to chase these lists! ...
    (alt.support.stop-smoking)
  • AS3 QuitList *OFFLIST* as of September 28, 2007
    ... Tom Westbrook ...tomAS3twestbrook.com ... Mark ..mark.weatherillAS3btinternet.com ... Steve ...steve.cooperAS3freeuk.com ... You see...it does pay to chase these lists! ...
    (alt.support.stop-smoking)
  • AS3 *OFFLIST* as of June 22, 2007 - **Please Read**
    ... Tom Westbrook ...tomAS3twestbrook.com ... Mark ..mark.weatherillAS3btinternet.com ... Steve ...steve.cooperAS3freeuk.com ... You see...it does pay to chase these lists! ...
    (alt.support.stop-smoking)
  • AS3 *OFFLIST* as of June 29, 2007 **Please Read**
    ... Tom Westbrook ...tomAS3twestbrook.com ... Mark ..mark.weatherillAS3btinternet.com ... Steve ...steve.cooperAS3freeuk.com ... You see...it does pay to chase these lists! ...
    (alt.support.stop-smoking)