-
Notifications
You must be signed in to change notification settings - Fork 0
/
domoves.ml
62 lines (50 loc) · 1.92 KB
/
domoves.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
open Common
open Getopt
let saveMoves' = ref true
let prefixMoves' = ref "moves"
let outdirMoves' = ref (Some !prefixMoves')
let prefixRanks' = ref "mrank"
let outdirRanks' = ref (Some !prefixRanks')
let mark' = ref ""
let specs =
[
(noshort,"prefixMoves",None,Some (fun x -> prefixMoves' := x));
(noshort,"outdirMoves",None,Some (fun x -> outdirMoves' := Some x));
(noshort,"nodirMoves", (set outdirMoves' None), None);
(noshort,"prefixRanks",None,Some (fun x -> prefixRanks' := x));
(noshort,"outdirRanks",None,Some (fun x -> outdirRanks' := Some x));
(noshort,"nodirRanks", (set outdirRanks' None), None);
('k',"mark",None,Some (fun x -> mark' := x))
]
let () =
let args = getOptArgs specs in
let saveMoves, mark =
!saveMoves', !mark' in
let prefixMoves, outdirMoves =
!prefixMoves', !outdirMoves' in
let prefixRanks, outdirRanks =
!prefixRanks', !outdirRanks' in
let bucksName,outdirRanks =
match args with
| bucksName::outdirRanks::restArgs -> bucksName,Some outdirRanks
| bucksName::restArgs -> bucksName,outdirRanks
| _ -> failwith "usage: domoves bucksName [outdir]"
in
let baseName = cutPathZ bucksName in
let ranksName = sprintf "%s-%s%s" prefixRanks mark baseName |> mayPrependDir outdirRanks in
let movesName = sprintf "%s-%s%s" prefixMoves mark baseName |> mayPrependDir outdirMoves in
leprintf "reading bucks from %s, saving moving ranks in %s" bucksName ranksName;
if saveMoves then
leprintfln ", saving moves themselves in %s" movesName
else
le_newline;
let bucks: day_buckets = loadData bucksName in
let moves: moving = Bucket_power.moving bucks in
let ranks: moving_ranks = Bucket_power.movingRanks moves in
if saveMoves then begin
mayMkDir outdirMoves;
saveData moves movesName
end
else ();
mayMkDir outdirRanks;
saveData ranks ranksName