From: John S. <sk...@us...> - 2005-06-09 23:33:14
|
On Thu, 2005-06-09 at 13:02 -0700, Martin Jambon wrote: > On Mon, 6 Jun 2005, Nicolas Cannasse wrote: > The following signatures seem good to me: > > (* Exception Remove can be raised by the user-given functions and means > "do not keep a binding to this key" for both union and inter. *) > > val union : > ('key -> 'a -> 'c) -> ('key -> 'a -> 'b -> 'c) -> ('key -> 'b -> 'c) -> > ('key, 'a) t -> ('key, 'b) t -> ('key, 'c) t > > val inter : > ('key -> 'a -> 'b -> 'c) -> ('key, 'a) t -> ('key, 'b) t -> ('key, 'c) t > > val diff : > ('key, 'a) t -> ('key, 'b) t -> ('key, 'a) t Just a minor comment, unrelated to the actual topic but concerning these names: it isn't clear from the name if 'diff' is setwise subtraction or symmetric difference. It isn't clear in the Ocaml standard library either. I believe 'diff' is actually subtraction, not the symmetric difference, which makes the choice of name extremely unfortunate. Both functions should be provided, they're both useful and expensive to compute with a multi-term expression eg: symdiff x y = sub (union x y) (inter x y) or sub x y = inter x (symdiff x y) Of course one can easily define both with only membership test and fold. Perhaps if the symmetric difference was provided and named symdiff it would be clear that 'diff' was the substraction. -- John Skaller, skaller at users.sf.net PO Box 401 Glebe, NSW 2037, Australia Ph:61-2-96600850 Download Felix here: http://felix.sf.net |