src/Pure/library.ML
changeset 18359 02a830bab542
parent 18333 b356f7837921
child 18376 2ef0183fa20b
equal deleted inserted replaced
18358:0a733e11021a 18359:02a830bab542
    99   val fold_rev: ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
    99   val fold_rev: ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
   100   val fold_map: ('a -> 'b -> 'c * 'b) -> 'a list -> 'b -> 'c list * 'b
   100   val fold_map: ('a -> 'b -> 'c * 'b) -> 'a list -> 'b -> 'c list * 'b
   101   val fold_index: (int * 'a -> 'b -> 'b) -> 'a list -> 'b -> 'b
   101   val fold_index: (int * 'a -> 'b -> 'b) -> 'a list -> 'b -> 'b
   102   val foldr1: ('a * 'a -> 'a) -> 'a list -> 'a
   102   val foldr1: ('a * 'a -> 'a) -> 'a list -> 'a
   103   val foldl_map: ('a * 'b -> 'a * 'c) -> 'a * 'b list -> 'a * 'c list
   103   val foldl_map: ('a * 'b -> 'a * 'c) -> 'a * 'b list -> 'a * 'c list
       
   104   val dig: ('a list -> 'a list) -> 'a list list -> 'a list list
   104   val unflat: 'a list list -> 'b list -> 'b list list
   105   val unflat: 'a list list -> 'b list -> 'b list list
   105   val splitAt: int * 'a list -> 'a list * 'a list
   106   val splitAt: int * 'a list -> 'a list * 'a list
   106   val dropwhile: ('a -> bool) -> 'a list -> 'a list
   107   val dropwhile: ('a -> bool) -> 'a list -> 'a list
   107   val nth: 'a list -> int -> 'a
   108   val nth: 'a list -> int -> 'a
   108   val nth_update: int * 'a -> 'a list -> 'a list
   109   val nth_update: int * 'a -> 'a list -> 'a list
   595       let val (ps,qs) = splitAt(length xs,ys)
   596       let val (ps,qs) = splitAt(length xs,ys)
   596       in ps :: unflat xss qs end
   597       in ps :: unflat xss qs end
   597   | unflat [] [] = []
   598   | unflat [] [] = []
   598   | unflat _ _ = raise UnequalLengths;
   599   | unflat _ _ = raise UnequalLengths;
   599 
   600 
       
   601 fun dig f xss =
       
   602   unflat xss ((f o flat) xss);
       
   603 
       
   604 
   600 (*like Lisp's MAPC -- seq proc [x1, ..., xn] evaluates
   605 (*like Lisp's MAPC -- seq proc [x1, ..., xn] evaluates
   601   (proc x1; ...; proc xn) for side effects*)
   606   (proc x1; ...; proc xn) for side effects*)
   602 val seq = List.app;
   607 val seq = List.app;
   603 
   608 
   604 (*separate s [x1, x2, ..., xn]  ===>  [x1, s, x2, s, ..., s, xn]*)
   609 (*separate s [x1, x2, ..., xn]  ===>  [x1, s, x2, s, ..., s, xn]*)