Skip to content
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

Merged
merged 10 commits into from
Dec 19, 2018
Merged

Added takewhile #54

merged 10 commits into from
Dec 19, 2018

Conversation

reinermartin
Copy link
Contributor

Added a takewhile function as discussed in issue "Would takewhile be a natural candidate for IterTools.jl?"

src/IterTools.jl Outdated Show resolved Hide resolved
@ararslan
Copy link
Member

The test failures should be fixed by simply adding takewhile to the list of exports.

@reinermartin
Copy link
Contributor Author

reinermartin commented Dec 17, 2018

The test failures should be fixed by simply adding takewhile to the list of exports.

Thanks, done that as well now

@codecov-io
Copy link

codecov-io commented Dec 17, 2018

Codecov Report

Merging #54 into master will increase coverage by 0.22%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/IterTools.jl 75.46% <83.33%> (+0.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64a14a8...16699ee. Read the comment docs.

@ararslan
Copy link
Member

Great work here!

@ararslan ararslan requested a review from iamed2 December 17, 2018 23:33
@reinermartin
Copy link
Contributor Author

Great work here!

Thanks for your help!

Copy link
Contributor

@iamed2 iamed2 left a 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)
Copy link
Contributor

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()
Copy link
Contributor

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.

@reinermartin
Copy link
Contributor Author

reinermartin commented Dec 18, 2018

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)

@iamed2 iamed2 merged commit 5e4844a into JuliaCollections:master Dec 19, 2018
@iamed2
Copy link
Contributor

iamed2 commented Dec 19, 2018

Lovely, thanks! I'll give #46 another look tomorrow and then I think I'll make a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants