home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
aijournl
/
aifirst.arc
/
TURBO2.LTG
< prev
Wrap
Text File
|
1986-10-30
|
836b
|
45 lines
Turbo PROLOG:
Database Access Benchmark
/* Test database storage and retrieval by asserting lots of facts and looking
them up. */
DATABASE
fact(INTEGER)
PREDICATES
test(INTEGER)
test2(INTEGER, INTEGER)
CLAUSES
/* Tail recursively look up a numbered fact in the database and the assert
its successor. First argument is current fact number, second argument
is limiting fact number to stop at. */
test2(X,X).
test2(X,Y) :- fact(X), Z = X + 1, assert(fact(Z)), test2(Z,Y).
/* Shorthand predicate to default the test to start with fact(1). */
test(Y) :- test2(1,Y).
fact(1). /* Seed the database with the first fact */
GOAL
/* Prompt for the limiting fact number and run the benchmark. */
nl, write(ready), nl, readint(X), test(X), write(done), nl.