take_while p xs
returns the longest initial segment of xs whose elements satisfy p
Source code:
set index 0 foreach x $xs { if { ![eval_unary $p $x] } { break } incr index } take $index $xs