This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

LengthWhile

LengthWhile
gives the number of continuous elements starting at the beginning of list for which is True.
Find the length of the run of elements below 10:
Find the length of the run of elements below 10:
In[1]:=
Click for copyable input
Out[1]=
Elements of the list can be any expression:
Use on an expression with head f:
The result is the same as for a list of the values:
Find the length of the run of digits in before a 7 occurs:
LengthWhile gives the length of the result from TakeWhile:
LengthWhile is equal to Length if is True for all elements:
Otherwise it is 1 less than the first position for which is not True:
The count terminates for any value of that is not True:
New in 6 | Last modified in 7