For the sake of brevity I’m leaving some of the more boilerplate functions out of this post. For the full code in each language, see the GitHub links above.
Disclosure: I am new to ClojureScript. Things in this post may be the wrong way of doing things. I am not a lawyer. Proceed with caution.
In Prim’s algorithm, on each turn we need to pick the opposite wall. The translation is pretty straightforward.
Frequently we need to see what’s at a certain coordinate in our graph data structure. Clojure’s get-in makes working with nested data structures ridiculously easy, since our coordinates (e.g. (y, x)) map directly to the nested data elements.
Place at coordinate
The opposite of our getter, at, above, place is our setter.
Here we’re using an outer IIFE to cycle through and find the first built-in requestAnimationFrame that exists. If it falls through, we simply supply a regular setTimeout.