Upgrade Ocamlformat version.
This commit is contained in:
@@ -1 +1 @@
|
|||||||
version = 0.26.2
|
version = 0.27.0
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
(** [pair_nums_from_string s] takes a string of two numbers separated by
|
(** [pair_nums_from_string s] takes a string of two numbers separated by
|
||||||
whitespace and returns the pair of the numbers *)
|
whitespace and returns the pair of the numbers *)
|
||||||
let pair_ints_of_string s =
|
let pair_ints_of_string s =
|
||||||
match Aoc.ints_of_string s with
|
match Aoc.ints_of_string ~sep:" " s with
|
||||||
| [ h; h' ] -> (h, h')
|
| [ h; h' ] -> (h, h')
|
||||||
| _ -> raise (Invalid_argument "pair_nums_from_string")
|
| _ -> raise (Invalid_argument "pair_nums_from_string")
|
||||||
|
|
||||||
(** [rev_split lst] takes a list of pairs and returns a pair of lists. Is
|
(** [rev_split lst] takes a list of pairs and returns a pair of lists. Is
|
||||||
equivalent to List.split (List.rev lst) but more efficient (and tail
|
equivalent to List.split (List.rev lst) but more efficient (and tail
|
||||||
recursive). *)
|
recursive). *)
|
||||||
let rev_split lst =
|
let rev_split lst =
|
||||||
let rec impl acc acc' = function
|
let rec impl acc acc' = function
|
||||||
@@ -16,7 +16,7 @@ let rev_split lst =
|
|||||||
impl [] [] lst
|
impl [] [] lst
|
||||||
|
|
||||||
(** [count lst n] counts the number of times [n] appears as an element in [lst].
|
(** [count lst n] counts the number of times [n] appears as an element in [lst].
|
||||||
*)
|
*)
|
||||||
let count lst n =
|
let count lst n =
|
||||||
List.fold_left (fun acc x -> if x = n then acc + 1 else acc) 0 lst
|
List.fold_left (fun acc x -> if x = n then acc + 1 else acc) 0 lst
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ let find_rule a b m =
|
|||||||
| Some s -> ( match IntSet.find_opt b s with Some _ -> true | None -> false)
|
| Some s -> ( match IntSet.find_opt b s with Some _ -> true | None -> false)
|
||||||
| None -> false
|
| None -> false
|
||||||
|
|
||||||
(** [compare m a b] is a total ordering on pages in the rule map [m]. Returns
|
(** [compare m a b] is a total ordering on pages in the rule map [m]. Returns
|
||||||
[-1] if [a] should appear before [b], [0] if [a = b], and [1] if [b] should
|
[-1] if [a] should appear before [b], [0] if [a = b], and [1] if [b] should
|
||||||
appear before [a]. *)
|
appear before [a]. *)
|
||||||
let compare m a b =
|
let compare m a b =
|
||||||
@@ -35,9 +35,9 @@ let rec is_page_order_valid m pages =
|
|||||||
in
|
in
|
||||||
match pages with h :: t -> impl h t && is_page_order_valid m t | [] -> true
|
match pages with h :: t -> impl h t && is_page_order_valid m t | [] -> true
|
||||||
|
|
||||||
(** [parse_rules lst] parses the rules in the list [lst] stopping when
|
(** [parse_rules lst] parses the rules in the list [lst] stopping when
|
||||||
encountering an empty line. Returns a pair [(rule_map, tail)].
|
encountering an empty line. Returns a pair [(rule_map, tail)]. [tail] starts
|
||||||
[tail] starts the line after the empty line. *)
|
the line after the empty line. *)
|
||||||
let parse_rules =
|
let parse_rules =
|
||||||
let m = Hashtbl.create 17 in
|
let m = Hashtbl.create 17 in
|
||||||
let rec impl = function
|
let rec impl = function
|
||||||
@@ -52,7 +52,7 @@ let parse_rules =
|
|||||||
in
|
in
|
||||||
impl
|
impl
|
||||||
|
|
||||||
(** [parse_page_orders lst] parses a list of page orders. *)
|
(** [parse_page_orders lst] parses a list of page orders. *)
|
||||||
let parse_page_orders =
|
let parse_page_orders =
|
||||||
let rec impl acc = function
|
let rec impl acc = function
|
||||||
| [] -> acc
|
| [] -> acc
|
||||||
|
17
lib/aoc.mli
17
lib/aoc.mli
@@ -1,18 +1,17 @@
|
|||||||
val ints_of_string : ?sep:string -> string -> int list
|
val ints_of_string : ?sep:string -> string -> int list
|
||||||
(** [nums_from_string ?sep s] takes a string of integers separated by [sep] and
|
(** [nums_from_string ?sep s] takes a string of integers separated by [sep] and
|
||||||
gives back a list of the integers. By default [sep] is " " *)
|
gives back a list of the integers. By default [sep] is " " *)
|
||||||
|
|
||||||
val distance1 : int -> int -> int
|
val distance1 : int -> int -> int
|
||||||
(** [distance1 a b] returns the absolute difference between [a] and [b]. *)
|
(** [distance1 a b] returns the absolute difference between [a] and [b]. *)
|
||||||
|
|
||||||
val strings_of_file : string -> string list
|
val strings_of_file : string -> string list
|
||||||
(** [strings_from_file fname] returns a list of strings from the file
|
(** [strings_from_file fname] returns a list of strings from the file [fname].
|
||||||
[fname]. Each string represents a line from the file. *)
|
Each string represents a line from the file. *)
|
||||||
|
|
||||||
val main : (string -> 'a) -> (('b -> string) * ('a -> 'b)) list -> unit
|
val main : (string -> 'a) -> (('b -> string) * ('a -> 'b)) list -> unit
|
||||||
(** [main prep parts] executes an advent of code problem. [prep fname] should
|
(** [main prep parts] executes an advent of code problem. [prep fname] should be
|
||||||
be a function that returns the input from [fname]. Each elemet of
|
a function that returns the input from [fname]. Each elemet of [parts] is a
|
||||||
[parts] is a pair of functions. The first converts the output to a string
|
pair of functions. The first converts the output to a string (for example
|
||||||
(for example [string_of_int]). The second executes the given part.
|
[string_of_int]). The second executes the given part. Output is given as if
|
||||||
Output is given as if done by:
|
done by: [print_string ( prep fname |> snd |> fst )] *)
|
||||||
[print_string ( prep fname |> snd |> fst )] *)
|
|
||||||
|
Reference in New Issue
Block a user