Function Repository Resource:

Excise

Source Notebook

Remove enclosed arguments

Contributed by: Wolfram Research Staff

ResourceFunction["Excise"][]

evaluates to an empty sequence, effectively removing its arguments without evaluation.

Details and Options

Excise has the attribute HoldAllComplete.

Examples

Basic Examples (3) 

Excise an argument of an expression:

In[1]:=
f[x, ResourceFunction["Excise"][y], z]
Out[1]=

Excise multiple arguments:

In[2]:=
f[x, ResourceFunction["Excise"][y, z]]
Out[2]=

Drop the second element of a list:

In[3]:=
\!\(\*
TagBox[
ButtonBox[
StyleBox["MapAt", "SymbolsRefLink",
ShowStringCharacters->True,
FontFamily->"Source Sans Pro",
"NodeID" -> 14],
BaseStyle->{"Link"},
ButtonData->"paclet:ref/MapAt"],
MouseAppearanceTag["LinkHand"]]\)[ResourceFunction[
 "Excise"], {1, 2, 3}, 2]
Out[3]=

Properties and Relations (3) 

An element to be excised is not evaluated:

In[4]:=
{a, ResourceFunction["Excise"][Print[b]], c}
Out[4]=

Excise[] always evaluates to Sequence[]:

In[5]:=
ResourceFunction["Excise"][x, y, z]
Out[5]=

When wrapped in a List, Excise is similar to Nothing&:

In[6]:=
{1, ResourceFunction["Excise"][2], 3}
Out[6]=
In[7]:=
{1, Nothing &[2], 3}
Out[7]=

Applications (1) 

Make some parts of a held expression "disappear" instead of evaluating when released:

In[8]:=
ResourceFunction["MapCases"][
 ResourceFunction["Excise"],
 HoldForm[{1 + 1, Print[2 + 2], Echo[3 + 3]}],
 _Print,
 Infinity
 ]
Out[8]=
In[9]:=
ReleaseHold[%]
Out[9]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 28 February 2019

License Information