This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/CHR/chr/getval.pl
vsc e5f4633c39 This commit was generated by cvs2svn to compensate for changes in r4,
which included commits to RCS files with non-trunk default branches.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@5 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2001-04-09 19:54:03 +00:00

53 lines
910 B
Prolog

%
% We use macros because because the
% bb operations are module specific.
% Thus the names are relative to the module
% loading this file
%
:- module( getval, []).
:- multifile
user:goal_expansion/3.
:- dynamic
user:goal_expansion/3.
user:goal_expansion( setval(Name,Value), _, bb_put(Name,Value)).
user:goal_expansion( getval(Name,Value), _, bb_get(Name,Value)).
user:goal_expansion( incval(Name,New), _, Exp) :-
Exp = (
bb_get( Name, Old),
New is Old+1,
bb_put( Name, New)
).
user:goal_expansion( decval(Name,New), _, Exp) :-
Exp = (
bb_get( Name, Old),
New is Old-1,
bb_put( Name, New)
).
end_of_file.
setval( Name, Value) :- bb_put( Name, Value).
getval( Name, Value) :- bb_get( Name, Value).
%
% ++i
%
incval( Name, New) :-
bb_get( Name, O),
New is O+1,
bb_put( Name, New).
%
% --i
%
decval( Name, New) :-
bb_get( Name, O),
New is O-1,
bb_put( Name, New).