File tree Expand file tree Collapse file tree 4 files changed +18
-26
lines changed Expand file tree Collapse file tree 4 files changed +18
-26
lines changed Original file line number Diff line number Diff line change @@ -112,23 +112,23 @@ let extract_input_output (edge : Ext_json_types.t) : string list * string list =
112
112
(match Ext_array. find_and_split content
113
113
(fun x () -> match x with Str { str =":" } -> true | _ -> false )
114
114
() with
115
- | ` No_split -> error ()
116
- | ` Split ( output , input ) ->
117
- (Ext_array. to_list_map (fun ( x : Ext_json_types.t ) ->
115
+ | No_split -> error ()
116
+ | Split ( output , input ) ->
117
+ (Ext_array. to_list_map output (fun x ->
118
118
match x with
119
119
| Str {str = ":" } ->
120
120
error ()
121
121
| Str {str } ->
122
122
Some str
123
- | _ -> None ) output
123
+ | _ -> None )
124
124
,
125
- Ext_array. to_list_map (fun ( x : Ext_json_types.t ) ->
125
+ Ext_array. to_list_map input (fun x ->
126
126
match x with
127
127
| Str {str = ":" } ->
128
128
error ()
129
129
| Str {str} ->
130
130
Some str (* More rigirous error checking: It would trigger a ninja syntax error *)
131
- | _ -> None ) input ))
131
+ | _ -> None ) ))
132
132
| _ -> error ()
133
133
type json_map = Ext_json_types .t Map_string .t
134
134
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ let rec tolist_aux a f i res =
112
112
| Some v -> v :: res
113
113
| None -> res)
114
114
115
- let to_list_map f a =
115
+ let to_list_map a f =
116
116
tolist_aux a f (Array. length a - 1 ) []
117
117
118
118
let to_list_map_acc a acc f =
@@ -187,13 +187,7 @@ let rfind_with_index arr cmp v =
187
187
else aux (i - 1 ) in
188
188
aux (len - 1 )
189
189
190
- type 'a split = [ `No_split | `Split of 'a array * 'a array ]
191
- let rfind_and_split arr cmp v : _ split =
192
- let i = rfind_with_index arr cmp v in
193
- if i < 0 then
194
- `No_split
195
- else
196
- `Split (Array. sub arr 0 i , Array. sub arr (i + 1 ) (Array. length arr - i - 1 ))
190
+ type 'a split = No_split | Split of 'a array * 'a array
197
191
198
192
199
193
let find_with_index arr cmp v =
@@ -207,9 +201,9 @@ let find_with_index arr cmp v =
207
201
let find_and_split arr cmp v : _ split =
208
202
let i = find_with_index arr cmp v in
209
203
if i < 0 then
210
- ` No_split
204
+ No_split
211
205
else
212
- ` Split (Array. sub arr 0 i, Array. sub arr (i + 1 ) (Array. length arr - i - 1 ))
206
+ Split (Array. sub arr 0 i, Array. sub arr (i + 1 ) (Array. length arr - i - 1 ))
213
207
214
208
(* * TODO: available since 4.03, use {!Array.exists} *)
215
209
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ val to_list_f :
49
49
('a -> 'b ) ->
50
50
'b list
51
51
52
- val to_list_map : ('a -> 'b option ) -> 'a array -> 'b list
52
+ val to_list_map :
53
+ 'a array -> ('a -> 'b option ) -> 'b list
53
54
54
55
val to_list_map_acc :
55
56
'a array ->
@@ -65,12 +66,9 @@ val of_list_map :
65
66
val rfind_with_index : 'a array -> ('a -> 'b -> bool ) -> 'b -> int
66
67
67
68
68
- type 'a split = [ `No_split | `Split of 'a array * 'a array ]
69
69
70
- val rfind_and_split :
71
- 'a array ->
72
- ('a -> 'b -> bool ) ->
73
- 'b -> 'a split
70
+ type 'a split = No_split | Split of 'a array * 'a array
71
+
74
72
75
73
val find_and_split :
76
74
'a array ->
Original file line number Diff line number Diff line change @@ -14,22 +14,22 @@ let suites =
14
14
__LOC__ > :: begin fun _ ->
15
15
Ext_array. find_and_split
16
16
[|" a" ; " b" ;" c" |]
17
- Ext_string. equal " --" =~ ` No_split
17
+ Ext_string. equal " --" =~ No_split
18
18
end;
19
19
__LOC__ > :: begin fun _ ->
20
20
Ext_array. find_and_split
21
21
[|" a" ; " b" ;" c" ;" --" |]
22
- Ext_string. equal " --" =~ ` Split ( [|" a" ;" b" ;" c" |],[||])
22
+ Ext_string. equal " --" =~ Split ( [|" a" ;" b" ;" c" |], [||])
23
23
end;
24
24
__LOC__ > :: begin fun _ ->
25
25
Ext_array. find_and_split
26
26
[|" --" ; " a" ; " b" ;" c" ;" --" |]
27
- Ext_string. equal " --" =~ ` Split ([||], [|" a" ;" b" ;" c" ;" --" |])
27
+ Ext_string. equal " --" =~ Split ([||], [|" a" ;" b" ;" c" ;" --" |])
28
28
end;
29
29
__LOC__ > :: begin fun _ ->
30
30
Ext_array. find_and_split
31
31
[| " u" ; " g" ; " --" ; " a" ; " b" ;" c" ;" --" |]
32
- Ext_string. equal " --" =~ ` Split ([|" u" ;" g" |], [|" a" ;" b" ;" c" ;" --" |])
32
+ Ext_string. equal " --" =~ Split ([|" u" ;" g" |], [|" a" ;" b" ;" c" ;" --" |])
33
33
end;
34
34
__LOC__ > :: begin fun _ ->
35
35
Ext_array. reverse [|1 ;2 |] =~ [|2 ;1 |];
You can’t perform that action at this time.
0 commit comments