title: How to bind var's name and value in the clojure macro?
body: <p>Assum I hava some(more than 20) variables, I want to save them to a file. I don't want to repeat 20 times the same code.
  I wrote a macro but it gave me an error.</p>
  
  <p>my test case:</p>
  
  <pre><code>;-----------------------------------------------
  (defn processor [ some-parameters ]
  
    (let [
    ;after some operation ,got these data:
          date-str ["JN01","JN02","JN03","JN04"];length 8760
          date-temperature (map #(str %2 "," %1) [3.3,4.4,5.5,6.6] date-str) ; all vector's length are 8760
          date-ws (map #(str %2 "," %1) [0.2,0.1,0.3,0.4] date-str)          ; 
          ;... many variables such like date-relative-humidity,date-pressure, name starts with "date-",
          ; all same size
          ]
      ;(doseq [e date-temperature]
      ;  (println e))
      (spit "output-variable_a.TXT"
            (with-out-str
              (doseq [e date-temperature]
                (println e))))
      ;same 'spit' part will repeat many times
      ))
  
  (processor 123)
  ; I NEED to output other variables(ws, wd, relative-humidity, ...)
  ; Output example:
  ;JN01,3.3
  ;JN02,4.4
  ;JN03,5.5
  ;JN04,6.6
  ;-----------------------------------------------
  </code></pre>
  
  <p>what I want is a macro/function I can use this way:</p>
  
  <pre><code>(write-to-text temperature,ws,wd,pressure,theta-in-k,mixradio)
  </code></pre>
  
  <p>and this macro/function will do the work.
  I don't know how to write such a macro/function.</p>
  
  <p>My macro post here but it doesn't work:</p>
  
  <pre><code>(defmacro write-array [&amp; rest-variables ]
    `(doseq [ vname# '~rest-variables ]
       ;(println vname# vvalue#)
       (println "the vname# is" (symbol vname#))
       (println "resolve:" (resolve (symbol (str vname# "-lines"))))
       (println "resolve2:" (resolve (symbol (str "ws-lines"))))
       (let [ vvalue# 5] ;(var-get (resolve (symbol vname#)))]
         ;----------NOTE:  commented out cause '(symbol vname#)' won't work.
         ;1(spit (str "OUT-" vname# ".TXT" )
         ;1      (with-out-str
         ;1        (doseq [ l (var-get (resolve (symbol (str vname# "-lines"))))]
         ;1          (println l))))
  
         (println vname# vvalue#))))
  </code></pre>
  
  <p>I found that the problem is <code>(symbol vname#)</code> part, this method only works for a <strong>GLOBAL</strong> variable, cannot bound to date-temperature <strong>in</strong> the <strong>LET</strong> form,<code>(symbol vname#)</code> returns nil.</p>