Wolfram Research

Function Repository Resource:

Slice

Source Notebook

An operator form of Part

Contributed by: Taliesin Beynon

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]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information