gives elements ei from the beginning of list, continuing so long as crit[ei] is True.
- TakeWhile can be used on an object with any head, not necessarily List.
Examplesopen allclose all
Basic Examples (2)
Take elements while they are all even:
Use a pure function to take elements while they are all below 10:
Elements of the list can be any expression:
Generalizations & Extensions (1)
Use on an expression with head f:
Find the digits of before the first occurrence of a 7:
Properties & Relations (3)
Possible Issues (1)
The list terminates for any value of crit[ei] that is not True:
Introduced in 2007
Updated in 2008