This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-12
Channels
@michael.e.loughlin Normally, in Clojure/Script, you'd just have a single atom with in your case a hash map of file paths to values. You can swap!
in new "file" contents with (swap! db assoc "path/to/file" new-contents)
and you can add new elements to files like this (swap! db assoc-in ["path/to/file" file-key] sub-content)
And your db
would be (atom {"path/to/file/1" {:a 1, :b 2} "path/to/another/file" {:x 22 :y 33}})
In general, the designed use case for atoms, refs, and agents is that if they contain immutable values, you are safe. If they themselves contain mutable values, I would think 7 times carefully about corner cases before relying on it.
Hi, is there a way to use quote/splice/eval to evaluate a defrecord
definition if I have a list of symbols? I have the following toy example:
Yes, you almost got it:
`(defrecord ~'Myrec [[email protected]])
That's with a backtick at the front`(~'defrecord ~'Myrec [[email protected]])
ah, thanks!
It depends if you want to use the defrecord defined in the namespace which is doing the expansion, or the one which is being expanded into.
I think I want the first one -- it expands to clojure.core/defrecord
, but I'm not sure which of those two options that fulfills...
Then you want:
`(defrecord ~'Myrec [[email protected]])
That means that even if there is a defrecord defined in the namespace being expanded into, it will still use the defrecord macro from clojure.core
Though the second answer above gives no namespace, so I think I'm seeing what you mean. So I think in my particular case it doesn't matter, since I don't redefine defrecord
, and will ultimately both resolve to clojure.core
. But this helps me sort some of this stuff...
Ya, its going to be rare, but say you gave it away as a library, you can't assume that the consumer didn't shadow defrecord (even if that be pretty weird in this case).
Hey guys, i would like to evaluate expressions in cursive ide similar to how it's done in this picture. Could anyone explain to me how this works?
I do not use Cursive and do not know the answer to your question. You may get an answer here, but in case not I wanted to mention that there is a #cursive channel in this Slack that the Cursive developer and others often answer questions
what you guys recommend as a math library? I need to use some optimizer such as Newton Raphson method,
Apache Commons Math library has one, and I suspect many, many other useful functions: https://commons.apache.org/proper/commons-math/javadocs/api-3.3/org/apache/commons/math3/analysis/solvers/NewtonRaphsonSolver.html
greaat!! Thanks @U0K064KQV o///