This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-23
Channels
- # arachne (3)
- # aws (1)
- # bangalore-clj (2)
- # beginners (19)
- # boot (151)
- # cider (72)
- # cljs-dev (9)
- # cljsjs (7)
- # cljsrn (37)
- # clojure (215)
- # clojure-austin (1)
- # clojure-denmark (2)
- # clojure-dev (68)
- # clojure-india (1)
- # clojure-ireland (2)
- # clojure-italy (4)
- # clojure-mke (1)
- # clojure-nl (4)
- # clojure-russia (4)
- # clojure-serbia (1)
- # clojure-spec (29)
- # clojure-uk (23)
- # clojurescript (23)
- # cursive (24)
- # datomic (71)
- # emacs (5)
- # events (1)
- # gsoc (11)
- # hoplon (20)
- # klipse (4)
- # lambdaisland (2)
- # leiningen (3)
- # luminus (3)
- # off-topic (30)
- # om (40)
- # om-next (1)
- # onyx (15)
- # pedestal (19)
- # perun (7)
- # planck (23)
- # proton (1)
- # protorepl (2)
- # re-frame (35)
- # reagent (21)
- # ring-swagger (38)
- # rum (19)
- # spacemacs (9)
- # untangled (11)
- # vim (5)
- # yada (4)
@simon Do you want to post that StackOverflow link in here so folks can take you through things step by step?
I see Alan Thompson has replied to your question on SO @simon -- if you have any questions about his response, feel free to ask them here and folks should be able to walk you through...
(but do remember it's nearly 10pm on West Coast of the US right now so not too many people will be around for a few hours! 🙂 )
The special form (..
part was helpful BUT my setup doesn't recognize the forv
function
@val_waeselynck here it is
@simon You want to use map
- https://clojuredocs.org/clojure.core/map
(map (fn [n] (calculate-distance-matrix 2 (define-context API-KEY) n)) (get-place-types))
@abarylko and the error message is?
@val_waeselynck error: package com.fasterxml.jackson.databind does not exist
in import com.fasterxml.jackson.databind.*;
@abarylko probably a classpath issue => use lein deps :tree
to debug it
@val_waeselynck I see this in my deps [com.fasterxml.jackson.core/jackson-core "2.8.6"]
wondering if I'm doing configuration wrong. config.edn has a map of with keys to function names, in the clj file the functions are defined, then the config file is loaded into a var, but when trying to use the function by dereferencing the key from the config map, it doesn't do anything. so {:afun some-fun} gets loaded into my-config after some-fun is defined in the namespace but then (def fun-results (map #((:afun my-config) % 10) some-list))
doesn't do anything. storing function names in a config file so you can swap out different functions for different environments seems like a pretty common use case. I might have made some silly 4am mistake but I figured I'd ask in beginners chat since for learning purposes
(let [configured-fun (resolve (:afun my-config))] (map #(configured-fun % 10) some-list))
I'm using clojure.edn/read-string to load the config which is safer than clojure.core/read-string which is why I have to do the extra step to resolve the function name
I guess I could use clojure.core/read-string since I trust the person that is writing the config file (me)
There’s no harm in resolving at runtime — and maintaining the safety of reading via pure EDN.
Are the functions in the same namespace?
If not, you probably need to require
their namespace before the resolve
.
(I’d be very wary of (def fun-results …)
since that will execute at load time — or worse, compile-time if you AOT — and that is almost certainly not when you want that to execute)
You almost never want def
with anything more that a very simple expression.