Skip to content
Snippets Groups Projects
Commit cae4b8d1 authored by Thorsten Wißmann's avatar Thorsten Wißmann :guitar:
Browse files

Normalize agent list

parent e2dc68f7
No related branches found
No related tags found
No related merge requests found
......@@ -11,10 +11,21 @@ module TArray = struct
any (fun y -> x == y) arr
let included sub sup = all (fun x -> elem x sup) sub
let to_string ts arr = "[| " ^ (Array.fold_right (fun i str -> (ts i) ^" "^ str) arr "|]")
let uniq arr =
let combine n l =
match l with
| [] -> [n]
| m::tail -> if n == m then l else n::l
in
Array.of_list (Array.fold_right combine arr [])
end
let agents = ref ([|1;2;3;4;5;6;7;8;9;10|])
let cl_get_agents () = !agents
let cl_set_agents arr = ignore (agents := arr)
let cl_set_agents arr = ignore (
agents := arr;
Array.fast_sort compare !agents;
agents := TArray.uniq !agents)
......@@ -7,6 +7,7 @@ module TArray : sig
val elem : 'a -> 'a array -> bool
val included : 'a array -> 'a array -> bool
val to_string : ('a -> string) -> 'a array -> string
val uniq : 'a array -> 'a array (* delete consecutive duplicates *)
end
val cl_get_agents : unit -> int array
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment