Bug 6104 – Add takeWhile to std.range.

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-06-04T13:35:00Z
Last change time
2015-06-09T05:13:45Z
Assigned to
nobody
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2011-06-04T13:35:01Z
std.range should provide a takeWhile(alias pred,R)(R arg) function, that returns its argument cut off at the first position where the predicate is false. This is particularly useful when dealing with infinite ranges. Example: assert(equal(takeWhile!"a<100"(recurrence!"a[n-2]+a[n-1]"(1,1))), [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]));
Comment #1 by timon.gehr — 2011-06-04T13:36:46Z
*** This issue has been marked as a duplicate of issue 4535 ***