# How can I perform this replacement? [closed]

I want to take an expression of the form

p[1,2]p[3,4]


and have an output of something like

{{1,2},{3,4}}


If I do the replacement

p[i_,j_]:>{i,j}


this ends up multiplying the two lists together, which I don't want. How can I do this? It also needs to be for an arbitrary number of p[i,j]

• p[1, 2] p[3, 4] /. {Times | p -> List} – Dr. belisarius Oct 12 '15 at 18:16
• List @@@ List @@ (p[1, 2] p[3, 4]) – march Oct 12 '15 at 20:22