home *** CD-ROM | disk | FTP | other *** search
-
-
- 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.
-
-