From 3068712ae965fd02dee2ddbf8967a0c946ea5a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= <edu@thorsten-wissmann.de> Date: Tue, 28 Jan 2014 23:49:57 +0100 Subject: [PATCH] Add coalgcompare subroutine genCL --- CoolUtils.ml | 1 + CoolUtils.mli | 2 ++ coalgcompare.ml | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/CoolUtils.ml b/CoolUtils.ml index bf60d09..d2da116 100644 --- a/CoolUtils.ml +++ b/CoolUtils.ml @@ -42,3 +42,4 @@ let cl_set_agents arr = ignore ( agents := TArray.uniq !agents) +let intlist_of_string str = List.map int_of_string (Str.split (Str.regexp "[ \t,]+") str) diff --git a/CoolUtils.mli b/CoolUtils.mli index 73e7e53..d8cd771 100644 --- a/CoolUtils.mli +++ b/CoolUtils.mli @@ -18,3 +18,5 @@ end val cl_get_agents : unit -> int array val cl_set_agents : int array -> unit +val intlist_of_string : string -> int list + diff --git a/coalgcompare.ml b/coalgcompare.ml index 81a9edb..30f86ab 100644 --- a/coalgcompare.ml +++ b/coalgcompare.ml @@ -231,9 +231,20 @@ let doGenCL aglist sizelist : unit = List.iter (fun sz -> printformula (genF sz)) sizelist let _ = + let argidx = ref (1) in + let fail str = raise (CoAlgFormula.CoAlgException (str)) in + let getarg () = + if !argidx >= Array.length Sys.argv then fail "Missing argument" else (); + let str = Sys.argv.(!argidx) in + argidx := 1 + !argidx; + str + in if Array.length Sys.argv < 2 then printUsage () else match Sys.argv.(1) with | "K" -> printRawData (doTestK ()) + | "genCL" -> let p1 = getarg () in + let p2 = getarg () in + doGenCL (intlist_of_string p1) (intlist_of_string p2) | _ -> raise (CoAlgFormula.CoAlgException ("Unknown Logic name »" ^ (Sys.argv.(1)) ^ "«")) -- GitLab