home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
prolog
/
library
/
diverses
/
scrtch.pro
< prev
next >
Wrap
Text File
|
1991-08-03
|
1KB
|
47 lines
/* Scratch Pad Utility */
domains
name = symbol
database
sp(name,real)
predicates
remember(name,real)
recall(name,real)
forget(name)
set_count(name)
count_up(name,real)
clr_sp
disp_sp
plus_sp(name,real,real)
minus_sp(name,real,real)
clauses
remember(Name,Value) :- asserta(sp(Name,Value)).
forget(Name) :- retract(sp(Name,_)).
recall(Name,Value) :- sp(Name,Value).
set_count(Name) :- asserta(sp(Name,0)).
count_up(Name,Value1) :- retract(sp(Name,Value)),
Value1=Value+1,
asserta(sp(Name,Value1)),!.
clr_sp :- retract(sp(_,_)),fail.
disp_sp :- sp(Name,Value),
write(Name,"\t",Value),nl,fail.
plus_sp(Name,Addend,Newvalue) :- recall(Name,Value),
Newvalue=Value+Addend,
forget(Name),
remember(Name,Newvalue).
minus_sp(Name,Addend,Newvalue) :- recall(Name,Value),
Newvalue=Value-Addend,
forget(Name),
remember(Name,Newvalue).