我正在使用Analemma库来制作一些svg数字.为了制作更复杂的数字,我想将svg分解成可以在不同函数中生成并传递给main svg函数的组件.简单的想法,对吗?
当我尝试传递一个值列表并且我不确定如何解决这个问题时,我一直被绊倒.在python中你可以使用解压缩列表*list,我想知道clojure中的等价物是什么.
如果没有相应的东西,我会欣赏有关如何实现同一目标的任何指示.
(use 'analemma.svg)
;set a line
(def oneline (->
(line 0 0 100 100)
(style :stroke "#006600" :stroke-width 3)))
;create an SVG by passing one or more line elements works fine
; this works
(svg oneline)
; so does this
(svg oneline oneline)
; but if i have a list of lines created in a different function i have a problem
(def manylines (repeat 5 oneline))
; this will not work
(svg manylines)
;I've tried the following but this doensn't work eaither becasue it mushes the list all together
(svg (apply concat manylines))
Run Code Online (Sandbox Code Playgroud)
谢谢zach cp
也许你正在寻找类似的东西
(apply svg manylines)
Run Code Online (Sandbox Code Playgroud)
这会产生相同的结果
(svg oneline oneline oneline oneline oneline)
Run Code Online (Sandbox Code Playgroud)