summaryrefslogtreecommitdiff
path: root/ocaml/lib/year2025/day02/part02/range.ml
blob: ba27568ce558c42476f00770e8d350972588ef0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
open Id

module Range = struct
  type t = ID.t * ID.t

  let create (id1, id2) = (ID.create id1, ID.create id2)

  let rec collect range = collect_range_aux [] range

  and collect_range_aux lst (id1, id2) =
    match id1 <= id2 with
    | false ->
        lst
    | true ->
        collect_range_aux (id1 :: lst) (ID.incr id1, id2)

  let pp (id1, id2) = "(L" ^ ID.pp id1 ^ ", R" ^ ID.pp id2 ^ ")"
end