1

Suppose Subscript[x, #] & /@ {1, 3, 7} that returns {x_1,x_3,x_7}. Now how can I get x_1x_3x_7?

Tried it already...

enter image description here

P.s. I am trying to understand this thread deeper about converting binary mlfs to mlfs.

hhh
  • 2,603
  • 2
  • 19
  • 30

2 Answers2

5

It is due to precedence. Need to use () in this case.

Times @@ (Subscript[x, #] & /@ {1, 3, 7})

Mathematica graphics

See this when-is-fg-not-the-same-as-fg topic for table of precedence in Mathematica.

Nasser
  • 143,286
  • 11
  • 154
  • 359
  • Yes but my Mathematica is returning {x,3x,7x} -- oouch brackets missing?! So my version operated on the Subscript thing, not the whole thing. Thank you! +1 – hhh Nov 10 '13 at 19:27
3

Two more solutions:

Times @@ Thread@Subscript[x, {1, 3, 7}]

In the notebook it can be written more compactly

enter image description here

The second one shows the behavior of /@

Subscript[x, #] & /@ Unevaluated@Times[1, 3, 7]

enter image description here

ybeltukov
  • 43,673
  • 5
  • 108
  • 212