Skip to content

LengthWhile

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

LengthWhile[list, crit]
    Gives the length of the longest leading run of
    elements e for which crit[e] is True. Over an association, tests values.

Examples

All examples below are verified against the current Mathilda build.

In[1]:= TakeWhile[<|"a" -> 1, "b" -> 2, "c" -> 5, "d" -> 1|>, # < 3 &]
Out[1]= <|"a" -> 1, "b" -> 2|>

In[2]:= LengthWhile[<|"a" -> 1, "b" -> 2, "c" -> 5|>, # < 3 &]
Out[2]= 2

Implementation notes

Attributes: Protected.

Implementation status

Stable — documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

References