On Thu, Jan 09, 2014 at 04:21:10PM +0100, Pino Toscano wrote:
+ and set_operations op_string = + let currentopset = + match (!operations) with
No need for parentheses around !operations.
+ let n = ref op_name in + let remove = string_prefix op_name "-" in + if remove then + n := String.sub op_name 1 (String.length op_name - 1); + match !n with
This can be written a bit more naturally as ... let n, remove = if string_prefix op_name "-" then String.sub op_name 1 (String.length op_name-1), true else op_name, false in match n with ...
+ let f = if remove then Sysprep_operation.remove_defaults_from_set else Sysprep_operation.add_defaults_to_set in + f opset
You can actually write: (if remove then Sysprep_operation.remove_defaults_from_set else Sysprep_operation.add_defaults_to_set) opset I don't know which way you think is clearer, but I would avoid the >80 character lines.
+ "--operations", Arg.String set_operations, " " ^ s_"Enable/disable specific operations";
I'd also add an alias "--operation" (it would just do the same thing).
+let add_list_to_opset l s = + List.fold_left ( + fun acc elem -> + OperationSet.add elem acc + ) s l + +let remove_list_from_opset l set = + OperationSet.fold ( + fun elem opset -> + if List.exists ( + fun li -> + li.name = elem.name + ) l then + opset + else + OperationSet.add elem opset + ) set empty_set
OCaml Set has subset, intersection, difference operations if you need them. See /usr/lib64/ocaml/set.mli Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW