Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to evaluate the tensor product 10 times in a given list( {g,e,r})

Here I have evaluated for 3 times...

#\[TensorProduct]#\[TensorProduct]#&[{g,e,r}]
..
..

Evaluated for 6 times...

#\[TensorProduct]#\[TensorProduct]#\[TensorProduct]#\[TensorProduct]#\[TensorProduct]#&[{g,e,r}] (*n=6*)

Each time I need to include the tensor product on the list. Is there any better way to do this for large no.?

share|improve this question
up vote 2 down vote accepted

You can generate the chained function on-the-fly for each n:

ClearAll@chainTensorProduct
chainTensorProduct[list_, n_Integer] := Function[TensorProduct @@ ConstantArray[#, n]]@list

Example:

#\[TensorProduct]#\[TensorProduct]#&[{g, e, r}] == chainTensorProduct[{g, e, r}, 3]
(* True *)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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