Function Repository Resource:

# SpliceAt

Splice expressions at certain positions

Contributed by: Nikolay Murzin
 ResourceFunction["SpliceAt"][expr,{e1,e2,…},pos] splices expressions ei at position pos of expr. ResourceFunction["SpliceAt"][expr,{p1→{e11,e12,…},p2→{e21,e22,…},…}] splices expressions eij at corresponding positions pi. ResourceFunction["SpliceAt"][{e1,e2,…}, pos] represents an operator form that can be applied to an expression. ResourceFunction["SpliceAt"][{p1→{e11,e12,…},p2→{e21,e22,…},…}] represents an operator form with rules.

## Examples

### Basic Examples (3)

Splice a list of expressions inside another expression:

 In[1]:=
 Out[1]=

Splice at multiple positions:

 In[2]:=
 Out[2]=

Splice with rules:

 In[3]:=
 Out[3]=

### Scope (3)

Use Unevaluated to prevent premature evaluation:

 In[4]:=
 Out[4]=

Use RuleDelayed to delay evaluation for rules:

 In[5]:=
 Out[5]=

Use operator forms:

 In[6]:=
 Out[6]=
 In[7]:=
 Out[7]=

### Properties and Relations (4)

In most cases, SpliceAt is just equivalent to Insert with Sequence:

 In[8]:=
 Out[8]=
 In[9]:=
 Out[9]=

But Insert will not work at deeper than first level inside held arguments:

 In[10]:=
 Out[10]=

While SpliceAt works as expected:

 In[11]:=
 Out[11]=

Also Insert does not support multiple insertions, while SpliceAt does:

 In[12]:=
 Out[12]=

### Possible Issues (2)

Root position is invalid:

 In[13]:=
 Out[13]=

 In[14]:=
 Out[14]=

## Version History

• 1.0.0 – 19 April 2022

## Author Notes

Main motivation was to splice inside held arguments