[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to use the Global variables on the GNU Prolog ?
From: |
Vic Bancroft |
Subject: |
Re: How to use the Global variables on the GNU Prolog ? |
Date: |
Mon, 21 Feb 2005 00:37:30 -0500 |
User-agent: |
Mozilla Thunderbird 0.9 (X11/20041127) |
Simple User wrote:
How to use the Global variables on the GNU Prolog?
If you intend to have a prolog database, then the most natural fit might
be to assert literals. Just use a dynamic/1 directive and simply assert
and retract them.
:- dynamic( atom_counter/2 ).
/** counters( +Name, -Number )
*
* Given an atom, records an incrementing number, begining with zero.
*
*/
counters( Name, Number ) :-
atom_counter( Name, LastNumber ),
retract( atom_counter( Name, LastNumber ) ),
Number is LastNumber + 1,
assertz( atom_counter( Name, Number ) ),
!.
counters( Name, 0 ) :-
assertz( atom_counter( Name, 0 ) ),
!.
I want a sample.
For more context you are welcome to read,
http://elvis.dlogic.org/~bancroft/pub/gplfaq/faq_parse.pl
more,
l8r,
v