Suppose I have a list of pairs each containing an expression and an associated Graph object:


Now, I want to obtain a product of the each pair. I tried:

Times @@@ list

But, the problem is that of formatting, the expression gets completely mixed with the Graph object:

enter image description here

I want simple product without any further mixing:

enter image description here

How to achieve this? I tried playing around with HoldForm and Print, but I failed to get them to work.

  • 2
    $\begingroup$ Wrap the factor in HoldForm. $\endgroup$ – Szabolcs May 11 '18 at 17:32
  • $\begingroup$ @Szabolcs Cool! It worked $\endgroup$ – Subho May 11 '18 at 17:48
  • 1
    $\begingroup$ If it is just for displaying purposes then Row@*Reverse /@ list would also work. $\endgroup$ – Henrik Schumacher May 12 '18 at 7:15

This is based on @Szabolcs' neat comment:

With[{x = #[[1]], y = #[[2]]}, HoldForm[x] y] & /@ list

The result looks thus looks like:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.