home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
lifeos2.zip
/
LIFE-1.02
/
TESTS
/
LF
/
TERMSIZE.LF
< prev
next >
Wrap
Text File
|
1996-06-04
|
813b
|
27 lines
% Return a list containing the values of all features of X:
feature_values(X) -> map(project(2=>X),features(X)).
% Sum all the elements in a list:
sum([V|Vs]) -> V+sum(Vs).
sum([]) -> 0.
term_size(X) -> N |
V<<-@, % Create an anonymous persistent
% term for the result.
( V<<-term_explore(X,Seen), % Calculate the size.
fail % Remove effects of calculation.
;
N=copy_term(V) % Copy the result back to a normal
). % logical term.
term_explore(X,Seen) -> V |
( X===Seen, % Skip already-counted nodes.
!,
V=0
;
FV=feature_values(X), % Get the features of X.
X<-Seen, % Mark X as having been counted.
V=1+sum(map(term_explore(2=>Seen),FV))
).