size / length: printable length;
authorwenzelm
Fri, 31 Jul 1998 11:33:30 +0200
changeset 5229 7c8abffc4413
parent 5228 66925577cefe
child 5230 fdc28193ccf7
size / length: printable length;
src/Pure/Syntax/symbol.ML
--- a/src/Pure/Syntax/symbol.ML	Fri Jul 31 11:03:31 1998 +0200
+++ b/src/Pure/Syntax/symbol.ML	Fri Jul 31 11:33:30 1998 +0200
@@ -23,6 +23,8 @@
   val beginning: symbol list -> string
   val scan: string list -> symbol * string list
   val explode: string -> symbol list
+  val length: symbol list -> int
+  val size: string -> int
   val input: string -> string
   val output: string -> string
   val source: bool -> (string, 'a) Source.source ->
@@ -246,6 +248,12 @@
   end;
 
 
+(* printable length *)
+
+fun sym_length ss = foldl (fn (n, c) => if is_printable c then n + 1 else n) (0, ss);
+val sym_size = sym_length o sym_explode;
+
+
 (* input / output *)
 
 fun input str =
@@ -257,8 +265,10 @@
 val output = implode o map char o sym_explode;
 
 
-(*final declaration of this structure!*)
+(*final declarations of this structure!*)
 val explode = sym_explode;
+val length = sym_length;
+val size = sym_size;
 
 
 end;