+ let is_within_bounds t {Point.r; Point.k} =
+ match t with
+ | [||] -> assert false
+ | t ->
+ r >= 0 && r < Array.length t &&
+ k >= 0 && k < Array.length t.(0)
+
+ let neighborhood t point =
+ List.map Direction.all ~f:Direction.to_offset
+ |> List.map ~f:(fun offset_point -> Point.(point + offset_point))
+ |> List.filter ~f:(is_within_bounds t)
+
+ let get_neighbors t point =
+ List.map (neighborhood t point) ~f:(get t)