Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Singleton/Logtalk/singleton-1.logtalk
Normal file
16
Task/Singleton/Logtalk/singleton-1.logtalk
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
:- object(singleton).
|
||||
|
||||
:- public(value/1).
|
||||
value(Value) :-
|
||||
state(Value).
|
||||
|
||||
:- public(set_value/1).
|
||||
set_value(Value) :-
|
||||
retract(state(_)),
|
||||
assertz(state(Value)).
|
||||
|
||||
:- private(state/1).
|
||||
:- dynamic(state/1).
|
||||
state(0).
|
||||
|
||||
:- end_object.
|
||||
7
Task/Singleton/Logtalk/singleton-2.logtalk
Normal file
7
Task/Singleton/Logtalk/singleton-2.logtalk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
| ?- singleton::value(Value).
|
||||
Value = 0
|
||||
yes
|
||||
|
||||
| ?- singleton::(set_value(1), value(Value)).
|
||||
Value = 1
|
||||
yes
|
||||
Loading…
Add table
Add a link
Reference in a new issue