LengthWhile

LengthWhile[list,crit]

gives the number of contiguous elements ei starting at the beginning of list for which crit[ei] is True.

Details

  • LengthWhile can be used on an object with any head, not necessarily List.

Examples

open allclose all

Basic Examples  (1)

Find the length of the run of elements below 10:

In[1]:=
Click for copyable input
Out[1]=

Scope  (1)

Generalizations & Extensions  (1)

Applications  (1)

Properties & Relations  (3)

Possible Issues  (1)

See Also

Length  Position  TakeWhile  CountDistinctBy  FirstPosition

Tutorials

Introduced in 2007
(6.0)
| Updated in 2008
(7.0)