I’m trying to model a 2d grid of coordinates as a nested object like I would normally do in JavaScript. How can I do something like this in ReasonML? The closest thing I’ve found would be Js.Dict. Is there another way to do this using pure ReasonML / Ocaml data structures?
let grid = {};
function insert(row, col){
grid[row] = grid[row] || {};
grid[row][col] = true;
}
//insert coordinate with (row, col)=(2,3)
insert(2,3);
// lookup same coordinate
grid[2][3] == true
edit: I’m also open to using full bucklescript constructs like Js.Dict or something else. I’m pretty new to it, but Js.Dict seems more verbose, and defaults to having keys as strings, though maybe both of these limitations can be overcome once I understand Js.Dict a little more.