# HG changeset patch # User wenzelm # Date 1189947146 -7200 # Node ID 1547ea587f5a23f7ba12a12b1dd1c85b99e34c63 # Parent dfea1edbf711ba1521ad4043c289806c0f176232 added some int constraints (ML_Parse.fix_ints not active here); diff -r dfea1edbf711 -r 1547ea587f5a src/Pure/General/symbol.ML --- a/src/Pure/General/symbol.ML Sat Sep 15 19:29:29 2007 +0200 +++ b/src/Pure/General/symbol.ML Sun Sep 16 14:52:26 2007 +0200 @@ -499,7 +499,7 @@ val xsymbolsN = "xsymbols"; fun sym_len s = - if not (is_printable s) then 0 + if not (is_printable s) then (0: int) else if String.isPrefix "\\> cons x; (*take the first n elements from a list*) -fun take (n, []) = [] +fun take (n: int, []) = [] | take (n, x :: xs) = if n > 0 then x :: take (n - 1, xs) else []; (*drop the first n elements from a list*) -fun drop (n, []) = [] +fun drop (n: int, []) = [] | drop (n, x :: xs) = if n > 0 then drop (n - 1, xs) else x :: xs; @@ -431,18 +431,18 @@ fun nth_map 0 f (x :: xs) = f x :: xs | nth_map n f (x :: xs) = x :: nth_map (n - 1) f xs - | nth_map _ _ [] = raise Subscript; + | nth_map (_: int) _ [] = raise Subscript; fun map_index f = let - fun mapp _ [] = [] - | mapp i (x :: xs) = f (i, x) :: mapp (i+1) xs + fun mapp (_: int) [] = [] + | mapp i (x :: xs) = f (i, x) :: mapp (i + 1) xs in mapp 0 end; fun fold_index f = let - fun fold_aux _ [] y = y - | fold_aux i (x :: xs) y = fold_aux (i+1) xs (f (i, x) y); + fun fold_aux (_: int) [] y = y + | fold_aux i (x :: xs) y = fold_aux (i + 1) xs (f (i, x) y); in fold_aux 0 end; val last_elem = List.last; @@ -454,7 +454,7 @@ (*find the position of an element in a list*) fun find_index pred = - let fun find _ [] = ~1 + let fun find (_: int) [] = ~1 | find n (x :: xs) = if pred x then n else find (n + 1) xs; in find 0 end; @@ -472,7 +472,7 @@ fun get_index f = let - fun get _ [] = NONE + fun get (_: int) [] = NONE | get i (x :: xs) = case f x of NONE => get (i + 1) xs @@ -497,7 +497,7 @@ | separate _ xs = xs; (*make the list [x, x, ..., x] of length n*) -fun replicate n (x: 'a) : 'a list = +fun replicate (n: int) x = let fun rep (0, xs) = xs | rep (n, xs) = rep (n - 1, x :: xs) in @@ -595,18 +595,18 @@ (** integers **) -fun inc i = (i := ! i + 1; ! i); -fun dec i = (i := ! i - 1; ! i); +fun inc i = (i := ! i + (1: int); ! i); +fun dec i = (i := ! i - (1: int); ! i); (* lists of integers *) (*make the list [from, from + 1, ..., to]*) -fun (i upto j) = +fun ((i: int) upto j) = if i > j then [] else i :: (i + 1 upto j); (*make the list [from, from - 1, ..., to]*) -fun (i downto j) = +fun ((i: int) downto j) = if i < j then [] else i :: (i - 1 downto j); @@ -732,7 +732,7 @@ if String.isSuffix sffx s then String.substring (s, 0, size s - size sffx) else raise Fail "unsuffix"; -fun replicate_string 0 _ = "" +fun replicate_string (0: int) _ = "" | replicate_string 1 a = a | replicate_string k a = if k mod 2 = 0 then replicate_string (k div 2) (a ^ a) @@ -1002,7 +1002,7 @@ else let val (ns, rest) = List.partition (p k) xs; in ns :: part(k+1)rest end - in part i end; + in part (i: int) end; fun partition_eq (eq:'a * 'a -> bool) = let @@ -1027,7 +1027,7 @@ val char_vec = Vector.tabulate (62, gensym_char); fun newid n = implode (map (fn i => Vector.sub (char_vec, i)) (radixpand (62, n))); -val gensym_seed = ref 0; +val gensym_seed = ref (0: int); in fun gensym pre = pre ^ newid (NAMED_CRITICAL "gensym" (fn () => inc gensym_seed)); @@ -1040,7 +1040,7 @@ val stamp: unit -> stamp = ref; type serial = int; -local val count = ref 0 +local val count = ref (0: int) in fun serial () = NAMED_CRITICAL "serial" (fn () => inc count) end; val serial_string = string_of_int o serial;