Fork me on GitHub

@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


@simon You want to use 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.