clojure-austin

https://www.meetup.com/Austin-Clojure-Meetup/
clojuregeek 2016-09-22T16:52:39.000071Z

is there a better way to take a map with string keys and convert to keyword keys?

clojuregeek 2016-09-22T16:52:50.000072Z

5 │ (defn props []
   6 │   (let [file (io/file "field-map.properties")
   7 │         data (p/load-from file)]
   8 │     (zipmap (map keyword (keys data)) (vals data)) ))

clojuregeek 2016-09-22T16:53:32.000073Z

{"two" "dos", "one" "uno", "three" "a long thing"} is what would be in data

2016-09-22T17:36:23.000075Z

There’s fmap

2016-09-22T17:36:32.000076Z

in contrib… let me see

2016-09-22T17:37:12.000077Z

actually - no fmap is for map keys

2016-09-22T17:38:32.000078Z

(into {} (for [[k v] data] [(keyword k)] v)

2016-09-22T17:39:03.000079Z

That’s an option, but zipmap reads pretty well

2016-09-22T17:39:28.000080Z

oh

2016-09-22T17:39:33.000081Z

(clojure.walk/keywordize-keys data)

2016-09-22T17:39:34.000082Z

duh

clojuregeek 2016-09-22T17:39:58.000083Z

ahh ok

clojuregeek 2016-09-22T17:46:42.000084Z

hmm so its not actually a map but a java.util.Properties object ...

clojuregeek 2016-09-22T17:46:47.000085Z

playing in repl

2016-09-22T17:46:55.000086Z

ah

clojuregeek 2016-09-22T17:47:09.000087Z

a is my object

(clojure.walk/keywordize-keys (into {}  a))

clojuregeek 2016-09-22T17:47:12.000088Z

that works

2016-09-22T17:47:44.000090Z

cool

clojuregeek 2016-09-22T17:48:04.000091Z

ok thanks 🙂

clojuregeek 2016-09-22T17:49:00.000092Z

ok i have another question

clojuregeek 2016-09-22T17:49:17.000093Z

i am making a war file and handing it to a guy

clojuregeek 2016-09-22T17:49:37.000094Z

that reads a properties file ... using clojurewerkz/propertied library ...

clojuregeek 2016-09-22T17:49:56.000095Z

if I read the file and store into a variable

clojuregeek 2016-09-22T17:50:09.000096Z

and compile to jar ....

clojuregeek 2016-09-22T17:50:15.000097Z

will the var work ?

clojuregeek 2016-09-22T17:50:33.000098Z

or will it contain the values it had when i first compiled ?

clojuregeek 2016-09-22T17:52:22.000099Z

i guess i can try it

clojuregeek 2016-09-22T18:18:14.000101Z

hmm i used clojure.walk by calling it fully qualified.. and when i make uberjar it complains

2016-09-22T18:23:54.000102Z

Did you require it?

clojuregeek 2016-09-22T19:10:39.000103Z

no

clojuregeek 2016-09-22T19:14:17.000104Z

ok it works now 😉

clojuregeek 2016-09-22T19:19:10.000105Z

and i answered my own questions 🙂

clojuregeek 2016-09-22T19:47:09.000106Z

clojure is the most awesome language

clojuregeek 2016-09-22T20:19:59.000107Z

open for any suggestions… a brief tour of clojure.. https://github.com/AustinClojure/workshop-docs/blob/add-basics/Pages/2-basics.md

clojuregeek 2016-09-22T20:20:17.000109Z

mainly for a reference during the workshop