diff options
| author | DJ O'Leary <dijitol@proton.me> | 2025-08-19 00:48:54 +0200 |
|---|---|---|
| committer | DJ O'Leary <dijitol@proton.me> | 2025-08-19 00:49:06 +0200 |
| commit | dbdeb7eaf3b92308e4895eb76dd9f3c5dae5b041 (patch) | |
| tree | ff33f18e876fd3e4b23492c6241b03061b741de0 /2024/OCaml/lib/grid/grid.ml | |
| parent | bb9b8f0d29195f19df38608af9371a18c45b6d61 (diff) | |
some change idk
Diffstat (limited to '2024/OCaml/lib/grid/grid.ml')
| -rw-r--r-- | 2024/OCaml/lib/grid/grid.ml | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/2024/OCaml/lib/grid/grid.ml b/2024/OCaml/lib/grid/grid.ml new file mode 100644 index 0000000..0d6bc4c --- /dev/null +++ b/2024/OCaml/lib/grid/grid.ml @@ -0,0 +1,14 @@ +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) |
