Apologies for the total noob question, rather struggling to get started with Clojure.
I have a string "buy=1|sell=2|limit=3|stop=4" and I am trying to turn it into a map
:buy 1
:sell 2
:limit 3
:stop 4
so far I have
(require '[clojure.string :as str])
=> nil
(def line "buy=1|sell=2|limit=3|stop=4")
=> #'user/line
(str/split line #"\|")
=> ["buy=1" "sell=2" "limit=3" "stop=4"]
now to split a second time i was thinking i wanted to map a function onto the seq, so something like
map (str/split #"\=") (str/split line #"\|")
=> ArityException Wrong number of args (1) passed to: string/split clojure.lang.AFn.throwArity (AFn.java:429)
I am trying to pass a partially applied function but doubt I have the syntax correct. I am passing the delimiter as the first argument to the function, however the string to be split should be passed first, so that is definitely incorrect.
Any pointers on a more idiomatic way to do this gratefully received.
(map #(str/split % #"\=") (str/split line #"\|"))(note the#(..%...)- cfrick