Reputation: 31003
I am using the Analemma library to make some svg figures. To make more complicated figures I wanted to break up the svg into components that could be generated in a different function and passed to the main svg
function. Simple enough idea, right?
Well I keep getting tripped up when I try to pass a list of values and am not really sure how to get around the issue. In python you would be able to unpack the list using *list
and I am wondering what an equivalent would be in clojure.
If there is no equivalent I wold appreciate any pointers about how to accomplish the same goal.
(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))
thanks zach cp
Upvotes: 0
Views: 1685
Reputation: 12090
maybe you are looking for something like
(apply svg manylines)
this would produce same result as
(svg oneline oneline oneline oneline oneline)
Upvotes: 7