Compare commits
2 Commits
812fa7498c
...
a2030efaca
Author | SHA1 | Date |
---|---|---|
Rhiannon Morris | a2030efaca | |
Rhiannon Morris | 9326f47ba2 |
2
day1.ml
2
day1.ml
|
@ -1,4 +1,4 @@
|
|||
module IntSet = Set_ext.Make(Int)
|
||||
module IntSet = Set.Make(Int)
|
||||
|
||||
let read_ints =
|
||||
Bracket.infile_lines ~line:int_of_string ~of_seq:IntSet.of_seq
|
||||
|
|
2
day4.ml
2
day4.ml
|
@ -17,7 +17,7 @@ let%test_module _ = (module struct
|
|||
end)
|
||||
|
||||
|
||||
module StrSet = Set_ext.Make(String)
|
||||
module StrSet = Set.Make(String)
|
||||
|
||||
let optional_fields = StrSet.singleton "cid"
|
||||
|
||||
|
|
2
day6.ml
2
day6.ml
|
@ -1,4 +1,4 @@
|
|||
module CharSet = Set_ext.Make(Char)
|
||||
module CharSet = Set.Make(Char)
|
||||
|
||||
let to_set str = String.to_seq str |> CharSet.of_seq
|
||||
|
||||
|
|
8
seq.ml
8
seq.ml
|
@ -50,13 +50,13 @@ let rec drop_while p seq =
|
|||
| Cons (x, xs) ->
|
||||
if p x then drop_while p xs else cons x xs
|
||||
|
||||
let chunks p =
|
||||
let chunks ~sep =
|
||||
unfold (fun seq ->
|
||||
match break' p seq with
|
||||
match break' sep seq with
|
||||
| Empty_seq -> None
|
||||
| Span (lst, seq) -> Some (lst, drop_while p seq))
|
||||
| Span (lst, seq) -> Some (lst, drop_while sep seq))
|
||||
|
||||
let line_chunks' = chunks (fun s -> s = "")
|
||||
let line_chunks' = chunks ~sep:(fun s -> s = "")
|
||||
let line_chunks ?(join=" ") seq = map (String.concat join) (line_chunks' seq)
|
||||
|
||||
let%test_module _ = (module struct
|
||||
|
|
2
seq.mli
2
seq.mli
|
@ -11,7 +11,7 @@ val break: ('a -> bool) -> 'a t -> 'a list * 'a t
|
|||
val drop_while: ('a -> bool) -> 'a t -> 'a t
|
||||
|
||||
|
||||
val chunks: ('a -> bool) -> 'a t -> 'a list t
|
||||
val chunks: sep:('a -> bool) -> 'a t -> 'a list t
|
||||
|
||||
val line_chunks': string t -> string list t
|
||||
val line_chunks: ?join:string -> string t -> string t
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
module type OrderedType = Stdlib.Set.OrderedType
|
||||
|
||||
module type S = sig
|
||||
include Set.S
|
||||
include Stdlib.Set.S
|
||||
val exists_opt: (elt -> 'a option) -> t -> 'a option
|
||||
end
|
||||
|
||||
module Make(Elt: Set.OrderedType) = struct
|
||||
include Set.Make(Elt)
|
||||
module Make(Elt: OrderedType) = struct
|
||||
include Stdlib.Set.Make(Elt)
|
||||
|
||||
let exists_opt (type a) (f: elt -> a option) set =
|
||||
let exception Found of a in
|
|
@ -0,0 +1,10 @@
|
|||
module type OrderedType = Stdlib.Set.OrderedType
|
||||
|
||||
module type S = sig
|
||||
include Stdlib.Set.S
|
||||
val exists_opt: (elt -> 'a option) -> t -> 'a option
|
||||
end
|
||||
|
||||
module Make(Elt: OrderedType): S
|
||||
with type elt = Elt.t
|
||||
and type t = Stdlib.Set.Make(Elt).t
|
|
@ -1,8 +0,0 @@
|
|||
module type S = sig
|
||||
include Set.S
|
||||
val exists_opt: (elt -> 'a option) -> t -> 'a option
|
||||
end
|
||||
|
||||
module Make(Elt: Set.OrderedType): S
|
||||
with type elt = Elt.t
|
||||
and type t = Set.Make(Elt).t
|
Loading…
Reference in New Issue