Re: How to use the Global variables on the GNU Prolog ?
Vic Bancroft <[email protected]>
| Newsgroups | gmane.comp.gnu.prolog.general |
|---|---|
| Message-ID | <[email protected]> |
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