Wolfram Computation Meets Knowledge

Slice

Contributed by: Taliesin Beynon

An operator form of Part

ResourceFunction["Slice"][i,j,][expr]

gives expri,j,〛.

Details and Options

ResourceFunction["Slice"][] represents an operator form of Part.

Examples

Basic Examples

Select the first element of a list using the operator form:

In[1]:=
ResourceFunction["Slice"][1][{2, 3}]
Out[1]=

An operator that selects the key in an association:

In[2]:=
slicer = ResourceFunction["Slice"]["a"];

Extract the value of “a”:

In[3]:=
slicer[<|"a" -> 1, "b" -> 2|>]
Out[3]=

Extract the first two key/value pairs using the operator form:

In[4]:=
ResourceFunction["Slice"][;; 2][<|"a" -> 1, "b" -> 2, "c" -> 3|>]
Out[4]=

Resource History