take_while


take_while(p, xs)
      

Return the longest prefix of elements from the sequence xs that satisfy the predicate p.

Examples:


take_while(is_positive, [1, 2, 3, -4, 5])
// [1, 2, 3]

function ints(n) n:~ints(n+1)
let s = ints(10)
take_while(^(x) x < 15, s)
// [10, 11, 12, 13, 14]
      

Also see:

drop_while
drop
take
filter


Core Module Index | Contents