1
$\begingroup$

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]

$\endgroup$

closed as off-topic by C. E., MarcoB, m_goldberg, Daniel Lichtblau, user9660 Oct 13 '15 at 5:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – C. E., MarcoB, m_goldberg, Daniel Lichtblau, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

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

Browse other questions tagged or ask your own question.