Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!harpo!seismo!hao!hplabs!sri-unix!pereira From: pereira@sri-unix.UUCP Newsgroups: net.sources Subject: Prolog library: flagro.pl Message-ID: <97@sri-unix.UUCP> Date: Mon, 15-Aug-83 01:52:16 EDT Article-I.D.: sri-unix.97 Posted: Mon Aug 15 01:52:16 1983 Date-Received: Wed, 10-Aug-83 02:12:14 EDT Lines: 46 /* FLAGRO.PL : Flag handling UTILITY Lawrence Updated: 30 March 81 */ %%% Compile this module %%% FLAGRO requires no other modules /* EXPORT */ :- public flag/3. /* MODES */ :- mode flag(+,?,?). % Flags are stored in the database keyed under the Flag itself with % the information packaged into a functor as follows: % % Flag --> '$flag'(Flag,Value) % % This routine maintains these flags returing previous values as Old and % updating the flag to New each time. The code actually checks to see if % this updating really requires changing the database. % flag(X,Old,New) :- nonvar(X), ( recorded(X,'$flag'(X,O),ID) ; O = 0 ), ( Old == New, !, Old = O ; !, Old = O, ( nonvar(ID), erase(ID) ; true ), recorda(X,'$flag'(X,New),_) ), !.