Re: Look for a mother of a child

Roelof Wobben <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
Thanks,


One last problem.


I want to print the answer in a sentence like this 


The mother of Child is Mother. 


So I tried this:



mother(Child):- 



 write('De moeder van'), 



write(Child), 



write('is'),




parent(X, Child),



female(X).



 write(X).




But I do not work. 

How can I make this work. 


Roelof



----------------------------------------
> Subject: Re: [SWIPL] Look for a mother of a child
> From: [email protected]
> Date: Sat, 8 Mar 2014 09:47:58 -0500
> To: [email protected]
>
> Your rule for mother/1 uses the lower case atom 'child', so it is only defined
> for this binding.
>
> I believe you want to rewrite as
>
> mother(Child) :- parent(X,Child), female(X).
>
>
> Vince Marchetti
>
> On Mar 8, 2014, at 9:09 AM, Roelof Wobben wrote:
>
>> Hello,
>>
>>
>> I have these facts:
>>
>>
>> male(roelof).
>>
>> male(mans).
>>
>> male(jan).
>>
>>
>> female(chantal).
>>
>> female(tamara).
>>
>> female(marie).
>>
>>
>> parent(roelof,tamara).
>>
>> parent(mans, roelof).
>>
>> parent(jan, chantal).
>>
>> parent(marie, roelof).
>>
>> parent(chantal, tamara).
>>
>>
>> mother(child):-
>>
>> parent(X, child),
>>
>> female(X).
>>
>>
>> But when I do mother(tamara). I see no where I expected to see chantal.
>>
>>
>> Did I do something wrong or does swi-prolog do something wrong ?
>>
>>
>> Roelof
>> _______________________________________________
>> SWI-Prolog mailing list
>> [email protected]
>> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
> Vincent Marchetti
> [email protected]
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.