Skip to main content
deleted 103 characters in body
Source Link
matheorem
  • 17.7k
  • 8
  • 53
  • 121

Ok. Here comes the Inactivate, Mathematica 10's powerful feature.

To replace something insideInactivate could not solve injecting expression into Hold, explicitly your question, use this.

Hold @@ (Inactivate @@ Hold[{1, 2, x}] /. x -> Sequence[3, 4]) (*Hold[1, 2, 3, 4]*) 

AndBut you mentioned you actually want to use this to inject Do iterator in Compile. This can be done directly by Inactivate without Hold stuff. Use this

Activate[Inactivate[Compile[{}, Do[code, iterators]]] /. iterators -> Sequence[{i, 5}, {j, 5}]] 

I personally think that with Inactivate and Activate, we can think many things differently now, especially meta programming.

Ok. Here comes the Inactivate, Mathematica 10's powerful feature.

To replace something inside Hold, explicitly your question, use this

Hold @@ (Inactivate @@ Hold[{1, 2, x}] /. x -> Sequence[3, 4]) (*Hold[1, 2, 3, 4]*) 

And you mentioned you actually want to use this to inject Do iterator in Compile. This can be done directly by Inactivate without Hold stuff. Use this

Activate[Inactivate[Compile[{}, Do[code, iterators]]] /. iterators -> Sequence[{i, 5}, {j, 5}]] 

I personally think that with Inactivate and Activate, we can think many things differently now, especially meta programming.

Ok. Here comes the Inactivate, Mathematica 10's powerful feature.

Inactivate could not solve injecting expression into Hold.

But you mentioned you actually want to use this to inject Do iterator in Compile. This can be done directly by Inactivate without Hold stuff. Use this

Activate[Inactivate[Compile[{}, Do[code, iterators]]] /. iterators -> Sequence[{i, 5}, {j, 5}]] 

I personally think that with Inactivate and Activate, we can think many things differently now, especially meta programming.

Source Link
matheorem
  • 17.7k
  • 8
  • 53
  • 121

Ok. Here comes the Inactivate, Mathematica 10's powerful feature.

To replace something inside Hold, explicitly your question, use this

Hold @@ (Inactivate @@ Hold[{1, 2, x}] /. x -> Sequence[3, 4]) (*Hold[1, 2, 3, 4]*) 

And you mentioned you actually want to use this to inject Do iterator in Compile. This can be done directly by Inactivate without Hold stuff. Use this

Activate[Inactivate[Compile[{}, Do[code, iterators]]] /. iterators -> Sequence[{i, 5}, {j, 5}]] 

I personally think that with Inactivate and Activate, we can think many things differently now, especially meta programming.