|
Jo posted:I'm going to harken back to the Sieve of Eratosthenes question from page 4. Clojure is totally cool with your mutable state. If you want to mutate a huge matrix while using idiomatic code, I'd recommend that you use "transients" (http://clojure.org/reference/transients). Clojure's vectors are capable of transient operations, so you should be able to represent your matrix as a transient vector of transient vectors. You can code like it's Clojure and consume memory like it's imperative code manipulating one global blob of memory! There are also matrix libraries you could look at, like https://github.com/mikera/core.matrix. I have no experience with it, but you might take a look. Finally, I suggest that you not worry about memory consumption before writing the code. Instead, I think you should write your code first, then determine if it's too slow or too memory-heavy, and then consider ways to deal with it. Unless you've already written some code and observed a memory problem, you are currently engaged in premature optimization.
|
# ¿ Mar 7, 2016 01:51 |
|
|
# ¿ May 16, 2024 00:35 |