This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-07
Channels
- # admin-announcements (19)
- # announcements (1)
- # beginners (14)
- # boot (244)
- # cider (2)
- # clojure (23)
- # clojure-dev (23)
- # clojure-poland (55)
- # clojure-russia (118)
- # clojure-uk (4)
- # clojurescript (143)
- # core-async (31)
- # core-logic (1)
- # cursive (30)
- # datascript (2)
- # datomic (3)
- # emacs (7)
- # hoplon (40)
- # ldnclj (8)
- # off-topic (2)
- # om (64)
- # reagent (10)
- # ring (1)
- # yada (71)
I’ve got a map with some values and I’m trying to calculate a bunch of derived values (that can depend on each other) and add them to the map. Is there any more elegant/idiomatic way than a giant let with a giant assoc?
(defn example [m]
(let [{:keys [a b c]} m]
(merge m
{:x (some-func a b)
:y (some-func-2 b c)
:z (some-func-3 x y)})))
or
(defn example [m]
(let [{:keys [a b c]} m]
(assoc m
:x (some-func a b)
:y (some-func-2 b c)
:z (some-func-3 x y))))
oh cool, I didn’t realize merge/assoc would create bindings like that
hmm, that doesn’t actually seem to work
(merge {} {:x 1 :y (inc x)})
just complains about “unable to resolve symbol: x"
yeah, that's not a thing :)
@tim.mccarthy: A bit of a tangent, but depending on how many derived values you're dealing with, something like javelin might suit your needs. https://github.com/hoplon/javelin
it’s less than 10, so I think it’s probably OK to bite the bullet and do the ugly thing rather than pull in a dependency, but that is pretty cool
Is there any good reference material for setting up orgmode to run clojure source blocks?
@gadfly361: I took the easy way out and used emacs-live as my base. http://overtone.github.io/emacs-live/
Thanks! Emacs live is pretty slick! Just updated my question to ask more specifically about clojure source blocks in orgmode, have you had success with that before?
@gadfly361: I've never tried doing that. Sorry.