# Using list elements as function calls ?

Is it possible to take elements of a matrix or list and use them as arguments of a function? I have a matrix of values, something like this;

  listed = {{3, 2, 1 , 5, 3, 2, 1}, {2, 3, 1, 4, 2, 1, 1}, {5, 1, 7, 5,  2, 1, 1}};


Now, if we take a function like Cylinder it requires something of the form;

 Graphics3D[Cylinder[{{x1,y1,z1},{x2,y2,z2}},t]]


with 7 arguments to specify it. What I'd like to do is take the rows of the columns and call these in, and do this for every row in the most automated fashion possible.In the example matrix I'd like Mathematica to render something like the image below -

This should be simple, but I'm running into problems. I've tried using forms of MapIndexed and Apply, but have had no joy and am open to suggestion on the best approach, as eventually I'll have to apply this so much bigger data sets than 7 x 3 !

Graphics3D[Cylinder[{{#1, #2, #3}, {#4, #5, #6}}, #7] & @@@ listed]


Or

Graphics3D[Cylinder[ArrayReshape[{##}, {2, 3}], #7] & @@@ listed]


Or

MapThread[Cylinder[ArrayReshape[{##}, {2, 3}], #7] &, Transpose@listed] // Graphics3D


Or

Graphics3D[Cylinder[ArrayReshape[#, {2, 3}], #[[-1]]] & /@ listed]

• The last one is best if listed is packed as Map will only unpack the top level. Mar 13, 2015 at 12:55
• These are brilliant - thanks so much! I need to learn the nature of the @@@ handles a little better...
– DRG
Mar 13, 2015 at 13:16
listed = {{3, 2, 1, 5, 3, 2, 1}, {2, 3, 1, 4, 2, 1, 1}, {5, 1, 7, 5,
2, 1, 1}};

Graphics3D[Cylinder[{#[[1 ;; 3]], #[[4 ;; 6]]}, #[[7]]] & /@ listed]