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 (2)

Every input below was run against the current Mathilda build and its output recorded.

Basic examples (2)

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.

References

See also: TakeWhile