Function Repository Resource:

# TakeAfter

Take elements after a specified element in an expression

Contributed by: Wolfram Staff
 ResourceFunction["TakeAfter"][list,pattern,n] takes the first n elements of list after the first occurrence of pattern. ResourceFunction["TakeAfter"][list,pattern,n,levelspec] takes elements on levels specified by levelspec. ResourceFunction["TakeAfter"][pattern,n,…] represents an operator form of ResourceFunction["TakeAfter"] that can be applied to an expression.

## Details and Options

ResourceFunction["TakeAfter"] accepts the following elements of the standard sequence specification:
 All all elements None no elements n elements 1 through n UpTo[n] up to n elements, as available
ResourceFunction["TakeAfter"] can be used on an object with any head, not necessarily List.
levelspec can be specified using the standard level specification, as used, for instance, in Cases.
The default value for levelspec in ResourceFunction["TakeAfter"] is {1}.
With the option setting , ResourceFunction["TakeAfter"] looks at heads of expressions and their parts.
ResourceFunction["TakeAfter"][pattern,n,][list] is equivalent to ResourceFunction["TakeAfter"][list,pattern,n,].

## Examples

### Basic Examples (5)

Take the first two elements after the element b in a list:

 In[1]:=
 In[2]:=
 Out[2]=

Do the same using the operator form of TakeAfter:

 In[3]:=
 Out[3]=

Take all elements after b:

 In[4]:=
 Out[4]=

Take elements from an expression with an arbitrary head:

 In[5]:=
 Out[5]=

Take as many elements as possible, up to 20:

 In[6]:=
 Out[6]=

Take the first three elements after the element c at level 2:

 In[7]:=
 Out[7]=

### Options (2)

By default, TakeAfter does not include heads of expression when creating a list of elements to match against the specified pattern:

 In[8]:=
 Out[8]=