-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added takewhile #54
Added takewhile #54
Conversation
The test failures should be fixed by simply adding |
Thanks, done that as well now |
Codecov Report
@@ Coverage Diff @@
## master #54 +/- ##
==========================================
+ Coverage 75.23% 75.46% +0.22%
==========================================
Files 1 1
Lines 210 216 +6
==========================================
+ Hits 158 163 +5
- Misses 52 53 +1
Continue to review full report at Codecov.
|
Great work here! |
Thanks for your help! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
src/IterTools.jl
Outdated
takewhile(cond, xs) = TakeWhile(cond, xs) | ||
|
||
function Base.iterate(it::TakeWhile, state=nothing) | ||
(val, state) = state == nothing ? iterate(it.xs) : iterate(it.xs, state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be state === nothing
val, state | ||
end | ||
|
||
Base.IteratorSize(it::TakeWhile) = Base.SizeUnknown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define IteratorEltype
and eltype
as well, like I did in Ivec
. Then you won't get Any
arrays returned.
iamed2, all your suggestion should be implemented, plus I fixed a bug (when condition was always true for a finite iterator it failed, I added @something to fix this) |
Lovely, thanks! I'll give #46 another look tomorrow and then I think I'll make a release. |
Added a takewhile function as discussed in issue "Would takewhile be a natural candidate for IterTools.jl?"