Family tree simple project

Discussions related to Visual Prolog
hadiranji
Posts: 11
Joined: 7 Dec 2013 15:16

Family tree simple project

Unread post by hadiranji » 7 Dec 2013 15:26

hi
i am new in visual prolog and i read some book about it but i can't define fact and rule in visual prolog
this is my program :

%fact
parent( pam, bob).
parent( bob, liz).

%rule
grandparent(X,Z):-parent( X, Y),parent( Y, Z).

%goal
edit3_ctl:setText=grandparent( edit1_ctl:getText(), edit2_ctl:getText()).

any body can give me this project in visual polog for helping me to start learning visual prolog ?

thanks

User avatar
Ferenc Nagy
VIP Member
Posts: 216
Joined: 24 Apr 2007 12:26

Family example of the Visual Prolog 5.2

Unread post by Ferenc Nagy » 10 Dec 2013 10:10

Hi,

The attached archive is the family example of the earlier version of Prolog.

Code: Select all

Here I quote the main code: /*****************************************************************************                   Copyright (c) 1984 - 2000 Prolog Development Center A/S    Project:  FAMILY  FileName: FAMILY.PRO  Purpose: No description  Written by: Visual Prolog  Comments: ******************************************************************************/     database - tmp   son(STRING,STRING)   sister(STRING,STRING)   brother(STRING,STRING)   married(STRING,STRING)   clauses   son("John","Dan").   sister("Mary","Suzan").   brother("Harold","Larry").   married("John","Mary").   married("Larry","Sue").   predicates   father(STRING father,STRING child)   grandfather(STRING grandfather,STRING grandchild)   sister_in_law(STRING,STRING)   clauses   father(A,B):-         son(B,A).     grandfather(A,B):-         father(A,C),         father(C,B).     sister_in_law(A,B):-         married(A,C),         sister(C,B).   sister_in_law(A,B):-         brother(A,C),         married(C,B).   goal   sister_in_law("John",Z),   format(Msg,"sister_in_law(\"John\",%)",Z),   write(Msg). %goal % sister_in_law("Harold",Z).
You can use in an Easywin project or add the "let us blind the peasant" MDI user interface.
You may continue like

predicates
cousin(string, string).
clauses
cousin(A,B) :-
grandfather(G,A),grandfather(G,B).
Attachments
VIP52_FAMILY_EXAMPLE.ZIP
(3.94 KiB) Downloaded 345 times
TIA, Regards,
Frank Nagy

User avatar
Thomas Linder Puls
VIP Member
Posts: 1174
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 11 Dec 2013 19:53

In the IDE: Help -> Install Examples... will install examples.

In the installed examples folder you will find the project _tutorial\family\family1\family1.prj6.

It contains the code corresponding to the tutorial: Fundamental Visual Prolog.
Regards Thomas Linder Puls
PDC

Post Reply