Group Abstract Group Abstract

Message Boards Message Boards

0
|
9K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

TakeWhile and Select

2 Replies

Thank you!

Posted 11 years ago

By definition,

Select[list,crit]

picks out ALL elements of the list for which crit is True.

whereas

TakeWhile[list,crit]

gives elements of the list from the beginning for which crit is True but stops at the value for which crit is not true. It doesn't evaluate further.

For e.g.

Select[{a, 1, 2, 3, b, c, 4, d, 5}, IntegerQ]
{1, 2, 3, 4, 5}

But

TakeWhile[{a, 1, 2, 3, b, c, 4, d, 5}, IntegerQ]
{}
POSTED BY: Girish Arabale
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard