(defun symbol-value-test ()
(-let (([a b c d e]
[1 2 3 4 5]))
(s-format "abcde\n${a}-${b}-${c}-${d}-${e}" 'aget
(--map (cons (symbol-name it) (symbol-value it)) '(a b c d e)))))
我希望得到
abcde
1-2-3-4-5
实际的需求会比这个更复杂一些,如果这种方式可以实现的话,我就不需要把(a b c d e)写两遍了。
比如按照-zip的话,我需要写成,
(defun symbol-value-test ()
(-let (([a b c d e]
[1 2 3 4 5]))
(s-format "abcde\n${a}-${b}-${c}-${d}-${e}" 'aget
(-zip '("a" "b" "c" "d" "e") (list a b c d e)))))
(defun symbol-value-test ()
(let* ((a 1)
(b (+ a 5))
(c (* a b))
(d (+ a b c))
(e (/ c d)))
(s-format "abcde\n${a}-${b}-${c}-${d}-${e}" 'aget
(-zip '("a" "b" "c" "d" "e") (list a b c d e)))))
(defun symbol-value-test ()
(let* ((a 1)
(b (+ a 5))
(c (* a b))
(d (+ a b c))
(e (/ c d))
(format1 (if (= b 6)
"abcde\n${a}-${b}-${c}-${d}-${e}"
"abcde\n${a}-${b}-${c}-${e}-${d}")))
(s-lex-format format1)))
(defun symbol-value-test ()
(let* ((a 1)
(b (+ a 5))
(c (* a b))
(d (+ a b c))
(e (/ c d)))
(if (= b 6)
(s-lex-format "abcde\n${a}-${b}-${c}-${d}-${e}")
(s-lex-format "abcde\n${a}-${b}-${c}-${e}-${d}"))))