Page 1 of 1
How to initialize single fact in a class that do not create object?
Posted: 19 Mar 2014 15:18
by yiding
Hi, there.
It is said that a single fact should be initialized in constructor. But if I have a class that do not create object, then it have no constructor,how to initialize my single fact?
By the way, what is the meaning of " <> " and " >< "? I can't find this two operators definition in anywhere.
Thanks!
Posted: 19 Mar 2014 16:05
by George
It is said that a single fact should be initialized in constructor. But if I have a class that do not create object, then it have no constructor,how to initialize my single fact?
Code:
Code: Select all
class facts
myFact : (string, string) single.
clauses
myFact("Test", "Cool").
%Fetch a value
Test():-
myFact(Test, Cool).
You need to have a class fact and define a fact with single
and you have to have one definition for that - that will be a default value - and you can't retract the single fact..
whenever you assert something that will get override
Ref the following URL for more detail
http://wiki.visual-prolog.com/index.php ... ence/Facts
Sympol: <> is used for not equality check
Ex : If you want to check two variable are not equal you can use "<>"
Code: Select all
%Fetch a value
Test():-
myFact(Test, Cool),
Test <> Cool.
For any personal support you can reach me at "
georgeananth.prolog@gmail.com"
Re:
Posted: 20 Mar 2014 2:18
by yiding
George wrote:It is said that a single fact should be initialized in constructor. But if I have a class that do not create object, then it have no constructor,how to initialize my single fact?
Code:
Code: Select all
class facts
myFact : (string, string) single.
clauses
myFact("Test", "Cool").
%Fetch a value
Test():-
myFact(Test, Cool).
You need to have a class fact and define a fact with single
and you have to have one definition for that - that will be a default value - and you can't retract the single fact..
whenever you assert something that will get override
Ref the following URL for more detail
http://wiki.visual-prolog.com/index.php ... ence/Facts
Sympol: <> is used for not equality check
Ex : If you want to check two variable are not equal you can use "<>"
Code: Select all
%Fetch a value
Test():-
myFact(Test, Cool),
Test <> Cool.
For any personal support you can reach me at "
georgeananth.prolog@gmail.com"
It is helpful,thank you!