% Code of Figure 7.5, page 280 from % Kenneth C. Louden, Programming Languages % Principles and Practice 2nd Edition % Copyright (C) Brooks-Cole/ITP, 2003 % NOTE: I have not checked this code % against a CLU compiler numcount = proc (s: string) returns (int); count: int = 0; for c: char in stringchars(s) do if numeric (c) then count := count + 1; end; end; return (count); end numcount; stringchars = iter (s: string) yields (char); index: int := 1; limit: int := string$size(s); while index <= limit do yield (string$fetch(s, index)) index := index + 1; end; end stringchars;