arguments - Clojure: Pass 'expanded' optional args to function -


i'm new clojure , i'm stuck on how 'expand' function's optional args can sent function uses optional args (but wants args keywords not seq of keywords).

i'm parsing xml , if hard code values below function works, walks xml , finds value of 'title':

; zd required [clojure.data.zip.xml :as zd] ; ... (defn get-node-value [parsed-xml & node-path]   (zd/xml-> (zip/xml-zip parsed-xml) :item :title zd/text))  (get-node-value parsed-xml) 

what want use 'node-path' pass in number of keywords, when written below comes in sequence of keywords throws exception:

(defn get-node-value [parsed-xml & node-path]   (zd/xml-> (zip/xml-zip parsed-xml) node-path zd/text))  (get-node-value parsed-xml :item :title) ; classcastexception clojure.lang.arrayseq cannot cast clojure.lang.ifn  clojure.data.zip/fixup-apply (zip.clj:73) 

thanks!

i think looking apply (http://clojuredocs.org/clojure_core/clojure.core/apply)

(defn get-node-value [parsed-xml & node-path]   (let [params (concat node-path [zd/text])]     (apply zd/xml-> (zip/xml-zip parsed-xml) params))) 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -