I would like to pass an array as the first argument to a pic.
However, the naive method doesn't work:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\tikzset{
ball/.pic = {
\draw [fill=red] (0,0) circle [radius=4mm];
},
balls/.pic = {
\foreach \pos in #1 {
\pic at (\pos,0) {ball};
}
}
}
\begin{document}
\begin{tikzpicture}
\draw (0,0) pic {balls={3,5}};
\end{tikzpicture}
\end{document}
I also tried with the syntax that should be used "for more complex arguments":
pics/balls/.style = {
code = {
\foreach \pos in #1 {
\pic at (\pos,0) {ball};
}
}
}
but this still does not work.
I know how to pass multiple arguments to a pic with /.style n args, however this is not what I'm trying to do.
How can this be achieved?

#1so it becomes{#1}in the first code – percusse Dec 16 '15 at 10:14#1in your case is an example. The other way is, say, http://tex.stackexchange.com/questions/261607/can-foreach-handle-list-of-lists and many others around the site – percusse Dec 16 '15 at 10:27