Subversion

2lt

?curdirlinks? - Rev 1

?prevdifflink? - Blame



types 

Ref = token;
WWW = map Ref to URL;
URL = seq of Unit;
Unit = PlainText | HyperLink;
PlainText = seq of Word;
Word = seq of char;
HyperLink :: link: Ref
             txt: PlainText



functions

wc : seq of char -> nat
wc(lst) == if lst = [] then 0 
          else let h = hd lst, 
                   t = tl lst
               in if (not sep(h)) and sepahead(t)
                  then wc(t) + 1
                  else wc(t);

sepahead: seq of char -> bool
sepahead(s) == (s = []) or sep(hd s);

sep: char -> bool 
sep(c) == c = ' ' or c = '\n' or c = '\t';

wc2 : PlainText -> nat
wc2 ( pt )  ==  if pt = [] 
                then 0
                else 1 + wc2( tl pt );

nrofwd : URL -> nat
nrofwd( url ) == if url = [] then 0
                 else if is_HyperLink(hd url) 
                      then wc2( (hd url).txt ) + nrofwd( tl url )
                      else wc2( hd url ) + nrofwd( tl url )



Theme by Vikram Singh | Powered by WebSVN v2.3.3