# HG changeset patch # User haftmann # Date 1136284275 -3600 # Node ID 5308a6ea3b96eb0a53303a9da5019a58251afd5b # Parent cb8e8fb9e52d5b14b4574e31118f8f5abd20b6af rearranged burrow_split to fold_burrow to allow composition with fold_map diff -r cb8e8fb9e52d -r 5308a6ea3b96 NEWS --- a/NEWS Tue Jan 03 00:06:30 2006 +0100 +++ b/NEWS Tue Jan 03 11:31:15 2006 +0100 @@ -228,14 +228,13 @@ * Pure/library: val burrow: ('a list -> 'b list) -> 'a list list -> 'b list list - val burrow_split: ('a list -> 'c * 'b list) -> 'a list list -> 'c * 'b list list + val fold_burrow: ('a list -> 'c -> 'b list * 'd) -> 'a list list -> 'c -> 'b list list * 'd The semantics of "burrow" is: "take a function with *simulatanously* transforms a list of value, and apply it *simulatanously* to a list of list of values of the appropriate type". Confer this with "map" which would *not* apply its argument function simulatanously but in -sequence. "burrow_split" allows the transformator function to yield an -additional side result. +sequence. "fold_burrow" has an additional context. Both actually avoid the usage of "unflat" since they hide away "unflat" from the user. diff -r cb8e8fb9e52d -r 5308a6ea3b96 src/Pure/library.ML --- a/src/Pure/library.ML Tue Jan 03 00:06:30 2006 +0100 +++ b/src/Pure/library.ML Tue Jan 03 11:31:15 2006 +0100 @@ -101,7 +101,7 @@ val foldr1: ('a * 'a -> 'a) -> 'a list -> 'a val foldl_map: ('a * 'b -> 'a * 'c) -> 'a * 'b list -> 'a * 'c list val burrow: ('a list -> 'b list) -> 'a list list -> 'b list list - val burrow_split: ('a list -> 'c * 'b list) -> 'a list list -> 'c * 'b list list + val fold_burrow: ('a list -> 'c -> 'b list * 'd) -> 'a list list -> 'c -> 'b list list * 'd val splitAt: int * 'a list -> 'a list * 'a list val dropwhile: ('a -> bool) -> 'a list -> 'a list val nth: 'a list -> int -> 'a @@ -607,8 +607,8 @@ fun burrow f xss = unflat xss ((f o flat) xss); -fun burrow_split f xss = - apsnd (unflat xss) ((f o flat) xss); +fun fold_burrow f xss s = + apfst (unflat xss) (f (flat xss) s); (*like Lisp's MAPC -- seq proc [x1, ..., xn] evaluates (proc x1; ...; proc xn) for side effects*)