home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
lifeos2.zip
/
LIFE-1.02
/
TESTS
/
LF
/
DICT.LF
< prev
next >
Wrap
Text File
|
1996-06-04
|
746b
|
27 lines
% Dictionary program in Life.
% Author: Peter Van Roy
% Insert, look up, or check a definition in an ordered binary tree
delay_check(tree)?
:: tree(name=>string,def=>string,left=>tree,right=>tree).
contains(tree(name=>N,def=>D), Name, Def) :-
Name=N, Def=D.
contains(tree(name=>N,left=>L), Name, Def) :-
N$>Name,
contains(L, Name, Def).
contains(tree(name=>N,right=>R), Name, Def) :-
N$=<Name,
contains(R, Name, Def).
main :-
CN="cat", CD="furry feline",
DN="dog", DD="furry canine",
contains(T,CN,CD), % Insert cat definition
contains(T,DN,DD), % Insert dog definition
contains(T,CN,Def), % Look up cat definition
write("A ",CN," is a ",Def),nl.