blob: 240fbc46b5e92c7d6eaa45826ea0c1d5977be9d9 (
plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
(* Programmed by Jedidiah Barber *)
(* Licensed under the Sunset License v1.0 *)
let usage_msg = "Usage: wallgen [options]"
let input_seq = ref (Array.make 0 (Z.of_int 0))
let depth_limit = ref 20
let use_random = ref false
let anon_fun item =
prerr_endline "Error: Don't know what to do with anonymous argument";
exit 2
let input_immediate items =
if Array.length !input_seq > 0 then
(prerr_endline "Error: Multiple input sequences specified";
exit 2)
else
try input_seq := Util.read_integer_list items
with Util.Not_an_integer s ->
prerr_endline ("Error: The argument '" ^ s ^ "' is not an integer");
exit 2
let input_from_file filename =
if Array.length !input_seq > 0 then
(prerr_endline "Error: Multiple input sequences specified";
exit 2)
else
try input_seq := Util.read_sequence_file filename
with Util.Not_an_integer s ->
prerr_endline ("Error: The item '" ^ s ^ "' from file '" ^ filename ^ "' is not an integer");
exit 2
let use_random len =
if Array.length !input_seq > 0 then
(prerr_endline "Error: Multiple input sequences specified";
exit 2)
else
input_seq := Sequence.random ~len
let speclist =
[("-f", Arg.String input_from_file, "Read input integer sequence from file");
("-i", Arg.String input_immediate, "Integer input sequence with values separated by commas");
("-l", Arg.Set_int depth_limit, "Sets maximum levels to generate, default 20");
("-r", Arg.Int use_random, "Use random input sequence of specified length")]
module My_Algebra =
struct
type t = Z.t
let zero = Z.zero
let one = Z.one
let add = Z.add
let sub = Z.sub
let mul = Z.mul
let div = Z.div
let to_string = Z.to_string
end
module My_Wall = Wall.Make (My_Algebra)
let _ =
if Array.length Sys.argv <= 1 then
(Arg.usage speclist usage_msg;
exit 1);
Arg.parse speclist anon_fun usage_msg;
if Array.length !input_seq = 0 then
(prerr_endline "Error: No input sequence provided";
exit 2);
let result =
My_Wall.create
~dimx:(Array.length !input_seq)
~dimy:!depth_limit
~init:!input_seq in
My_Wall.print result
|