Add some helpers to impldement %{deps[i]}
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
13c12e9def
commit
0195b4bd03
|
@ -13,3 +13,9 @@ include T
|
|||
|
||||
module Set = Set.Make(T)
|
||||
module Map = Map.Make(T)
|
||||
|
||||
let of_string_exn s =
|
||||
match int_of_string s with
|
||||
| exception Failure _ ->
|
||||
failwith (Printf.sprintf "of_string_exn: invalid int %S" s)
|
||||
| s -> s
|
||||
|
|
|
@ -3,3 +3,5 @@ val compare : t -> t -> Ordering.t
|
|||
|
||||
module Set : Set.S with type elt = t
|
||||
module Map : Map.S with type key = t
|
||||
|
||||
val of_string_exn : string -> t
|
||||
|
|
|
@ -104,3 +104,9 @@ let rec assoc t x =
|
|||
| (k, v) :: t -> if x = k then Some v else assoc t x
|
||||
|
||||
let singleton x = [x]
|
||||
|
||||
let rec nth t i =
|
||||
match t, i with
|
||||
| [], _ -> None
|
||||
| x :: _, 0 -> Some x
|
||||
| _ :: xs, i -> nth xs (i - 1)
|
||||
|
|
|
@ -40,3 +40,5 @@ val compare : 'a t -> 'a t -> compare:('a -> 'a -> Ordering.t) -> Ordering.t
|
|||
val assoc : ('a * 'b) t -> 'a -> 'b option
|
||||
|
||||
val singleton : 'a -> 'a t
|
||||
|
||||
val nth : 'a t -> int -> 'a option
|
||||
|
|
Loading…
Reference in New Issue