Add List.assoc
Signed-off-by: Jeremie Dimino <jdimino@janestreet.com>
This commit is contained in:
parent
b35fbbd7b2
commit
ed583b7651
|
@ -218,7 +218,7 @@ let bootstrap () =
|
|||
Arg.Symbol
|
||||
(List.map Config.Display.all ~f:fst,
|
||||
fun s ->
|
||||
display := Some (List.assoc s Config.Display.all))
|
||||
display := List.assoc Config.Display.all s)
|
||||
in
|
||||
let concurrency = ref None in
|
||||
let concurrency_arg x =
|
||||
|
|
|
@ -97,3 +97,8 @@ let rec compare a b ~compare:f : Ordering.t =
|
|||
match (f x y : Ordering.t) with
|
||||
| Eq -> compare a b ~compare:f
|
||||
| ne -> ne
|
||||
|
||||
let rec assoc t x =
|
||||
match t with
|
||||
| [] -> None
|
||||
| (k, v) :: t -> if x = k then Some v else assoc t x
|
||||
|
|
|
@ -36,3 +36,5 @@ val sort : 'a t -> compare:('a -> 'a -> Ordering.t) -> 'a t
|
|||
val stable_sort : 'a t -> compare:('a -> 'a -> Ordering.t) -> 'a t
|
||||
|
||||
val compare : 'a t -> 'a t -> compare:('a -> 'a -> Ordering.t) -> Ordering.t
|
||||
|
||||
val assoc : ('a * 'b) t -> 'a -> 'b option
|
||||
|
|
|
@ -60,9 +60,9 @@ let signal_name =
|
|||
]
|
||||
in
|
||||
fun n ->
|
||||
match List.assoc n table with
|
||||
| exception Not_found -> sprintf "%d\n" n
|
||||
| s -> s
|
||||
match List.assoc table n with
|
||||
| None -> sprintf "%d\n" n
|
||||
| Some s -> s
|
||||
|
||||
type target_kind =
|
||||
| Regular of string * Path.t
|
||||
|
|
|
@ -24,9 +24,9 @@ and postprocess tbl b = parse
|
|||
| eof { Buffer.contents b }
|
||||
| ([^ '/'] as c) (ext as e)
|
||||
{ Buffer.add_char b c;
|
||||
begin match List.assoc e tbl with
|
||||
| res -> Buffer.add_string b res
|
||||
| exception Not_found -> Buffer.add_string b e
|
||||
begin match List.assoc tbl e with
|
||||
| Some res -> Buffer.add_string b res
|
||||
| None -> Buffer.add_string b e
|
||||
end;
|
||||
postprocess tbl b lexbuf
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue