Function Repository Resource:

# DropWhile

Drop elements of a list while a criterion remains true

Contributed by: Sander Huisman
 ResourceFunction["DropWhile"][list,crit] drops elements ei from the beginning of list, continuing so long as crit[ei] is True. ResourceFunction["DropWhile"][crit] represents an operator form of ResourceFunction["DropWhile"] that can be applied to expressions.

## Details and Options

ResourceFunction["DropWhile"] can be used on an object with any head, not necessarily List.

## Examples

### Basic Examples (2)

Drop elements while they are even:

 In[1]:=
 Out[1]=

Use a pure function to drop elements while they are all below 10:

 In[2]:=
 Out[2]=

### Scope (2)

Elements of the list can be any expression:

 In[3]:=
 Out[3]=

Create an operator of DropWhile that drops leading even numbers:

 In[4]:=
 Out[4]=

Use the operator:

 In[5]:=
 Out[5]=

### Generalizations & Extensions (2)

Use on an expression with head f:

 In[6]:=
 Out[6]=

DropWhile also works on SparseArray:

 In[7]:=
 Out[7]=

### Applications (1)

 In[8]:=
 Out[8]=

### Properties and Relations (3)

DropWhile is equivalent to a combination of Drop and LengthWhile:

 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=
 In[11]:=
 Out[11]=

DropWhile gives an empty list if crit[ei] is True for all elements:

 In[12]:=
 Out[12]=

Combining the results of TakeWhile and DropWhile gives the original list:

 In[13]:=
 Out[14]=

### Possible Issues (1)

The list terminates for any value of crit[ei] that is not True:

 In[15]:=
 Out[15]=

SHuisman

## Requirements

Wolfram Language 11.3 (March 2018) or above

## Version History

• 1.0.0 – 19 April 2019