I want to define a new Product
but for NonCommutativeMultiply
, which I do something like this:
NCMProduct[expr_, iterator_] :=
NonCommutativeMultiply @@ Table[expr, iterator]
Is there any way for Mathematica to Block
the iterator automatically to the scope of NCMProduct
like it would for Product
?
So then I could use things like:
i = 3;
NCMProduct[f[i], {i, 5}]
Product[f[i], {i, 5}]
In this case, Product
will Block
out i
and the fact that I have assigned to i
doesn't matter, but NCMProduct
doesn't know that i
is going to be Block
ed inside its definition, and hence I get Table::itraw
, which isn't the behaviour I want.
I'd also like to have nice syntax highlighting for my NCMProduct
showing that i
is Block
ed in the front end if possible!