src/Pure/library.ML
changeset 20095 432e914a0e95
parent 20006 0f507e799938
child 20108 289050bdfff5
equal deleted inserted replaced
20094:99f27df2b6d0 20095:432e914a0e95
   161   val downto0: int list * int -> bool
   161   val downto0: int list * int -> bool
   162   val radixpand: int * int -> int list
   162   val radixpand: int * int -> int list
   163   val radixstring: int * string * int -> string
   163   val radixstring: int * string * int -> string
   164   val string_of_int: int -> string
   164   val string_of_int: int -> string
   165   val string_of_indexname: string * int -> string
   165   val string_of_indexname: string * int -> string
   166   val read_radixint: int * string list -> int * string list
   166   val read_intinf: int -> string list -> IntInf.int * string list
   167   val read_int: string list -> int * string list
   167   val read_int: string list -> int * string list
   168   val oct_char: string -> string
   168   val oct_char: string -> string
   169 
   169 
   170   (*strings*)
   170   (*strings*)
   171   val nth_string: string -> int -> string
   171   val nth_string: string -> int -> string
   821   | string_of_indexname (a,i) = a ^ "_" ^ Int.toString i;
   821   | string_of_indexname (a,i) = a ^ "_" ^ Int.toString i;
   822 
   822 
   823 
   823 
   824 (* read integers *)
   824 (* read integers *)
   825 
   825 
   826 fun read_radixint (radix: int, cs) : int * string list =
   826 fun read_intinf radix cs =
   827   let val zero = ord"0"
   827   let
   828       val limit = zero+radix
   828     val zero = ord "0";
   829       fun scan (num,[]) = (num,[])
   829     val limit = zero + radix;
   830         | scan (num, c::cs) =
   830     fun scan (num, []) = (num, [])
   831               if  zero <= ord c  andalso  ord c < limit
   831       | scan (num, c :: cs) =
   832               then scan(radix*num + ord c - zero, cs)
   832         if zero <= ord c andalso ord c < limit then
   833               else (num, c::cs)
   833           scan (IntInf.fromInt radix * num + IntInf.fromInt (ord c - zero), cs)
   834   in  scan(0,cs)  end;
   834         else (num, c :: cs);
   835 
   835   in scan (0, cs) end;
   836 fun read_int cs = read_radixint (10, cs);
   836 
   837 
   837 fun read_int cs = apfst IntInf.toInt (read_intinf 10 cs);
   838 fun oct_char s = chr (#1 (read_radixint (8, explode s)));
   838 
       
   839 fun oct_char s = chr (IntInf.toInt (#1 (read_intinf 8 (explode s))));
   839 
   840 
   840 
   841 
   841 
   842 
   842 (** strings **)
   843 (** strings **)
   843 
   844