diff options
| author | DJ O'Leary <dijitol@proton.me> | 2026-06-27 04:28:48 +0200 |
|---|---|---|
| committer | DJ O'Leary <dijitol@proton.me> | 2026-06-27 04:28:48 +0200 |
| commit | bc8b9edc0860f4804dfd0ea868ee7beaa564e62a (patch) | |
| tree | e1123d11627b4829586da3b097015b1dbb3d0285 /2024/ocaml/lib/grid | |
| parent | 976048a85403fbb0751c34fa42703a3c47f6e918 (diff) | |
Diffstat (limited to '2024/ocaml/lib/grid')
| -rw-r--r-- | 2024/ocaml/lib/grid/cell.ml | 18 | ||||
| -rw-r--r-- | 2024/ocaml/lib/grid/cell.mli | 18 | ||||
| -rw-r--r-- | 2024/ocaml/lib/grid/grid.ml | 14 | ||||
| -rw-r--r-- | 2024/ocaml/lib/grid/grid.mli | 6 |
4 files changed, 0 insertions, 56 deletions
diff --git a/2024/ocaml/lib/grid/cell.ml b/2024/ocaml/lib/grid/cell.ml deleted file mode 100644 index 186e451..0000000 --- a/2024/ocaml/lib/grid/cell.ml +++ /dev/null @@ -1,18 +0,0 @@ -type t = { - value : string; - up : t option; - down : t option; - left : t option; - right : t option; -} - -let create value = { value; up = None; down = None; left = None; right = None } -let with_up up c = { c with up = Some up } -let with_down down c = { c with down = Some down } -let with_left left c = { c with left = Some left } -let with_right right c = { c with right = Some right } -let move_up co = match co with Some c -> c.up | None -> None -let move_down co = match co with Some c -> c.down | None -> None -let move_left co = match co with Some c -> c.left | None -> None -let move_right co = match co with Some c -> c.right | None -> None -let ( = ) c1 c2 = c1.value = c2.value diff --git a/2024/ocaml/lib/grid/cell.mli b/2024/ocaml/lib/grid/cell.mli deleted file mode 100644 index e61e34a..0000000 --- a/2024/ocaml/lib/grid/cell.mli +++ /dev/null @@ -1,18 +0,0 @@ -type t = { - value : string; - up : t option; - down : t option; - left : t option; - right : t option; -} - -val create : string -> t -val with_up : t -> t -> t -val with_down : t -> t -> t -val with_left : t -> t -> t -val with_right : t -> t -> t -val move_up : t option -> t option -val move_down : t option -> t option -val move_left : t option -> t option -val move_right : t option -> t option -val ( = ) : t -> t -> bool diff --git a/2024/ocaml/lib/grid/grid.ml b/2024/ocaml/lib/grid/grid.ml deleted file mode 100644 index 0d6bc4c..0000000 --- a/2024/ocaml/lib/grid/grid.ml +++ /dev/null @@ -1,14 +0,0 @@ -let rec to_grid_aux tokens max_width acc = - match tokens with - | [] -> acc - | h :: t -> - let new_cell = Cell.create h |> Cell.with_left acc in - let new_acc = acc |> Cell.with_right new_cell in - to_grid_aux t max_width new_acc - -let to_grid tokens max_width : Cell.t option = - match tokens with - | [] -> None - | h :: t -> - let first_cell = Cell.create h in - Some (to_grid_aux t max_width first_cell) diff --git a/2024/ocaml/lib/grid/grid.mli b/2024/ocaml/lib/grid/grid.mli deleted file mode 100644 index a69fcfe..0000000 --- a/2024/ocaml/lib/grid/grid.mli +++ /dev/null @@ -1,6 +0,0 @@ -val to_grid : string list -> int -> Cell.t option -(** The cell in the top left corner of the grid is returned where each element - of [tokens] is converted into rows with [width]. An empty list of [tokens] - returns None. Requires: [width] is greater than 0 **) - -(* val print : Cell.t -> () *) |
