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

Add iterator chain from Iterators.jl #11842

Closed
wants to merge 1 commit into from
Closed

Add iterator chain from Iterators.jl #11842

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 24, 2015

Adding iterators was previously discussed in #10162. However, 'chain' was not included and it is among the features that I miss the most coming from Python and its itertools. All of the code was lifted over from Iterators.jl, I only made some minor modifications to the documentation. As always, feedback is most welcome.

# chain
# -----

@test collect(chain(1:2:5, 0.2:0.1:1.6)) == [1:2:5, 0.2:0.1:1.6]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be [1:2:5; 0.2:0.1:1.6] (to avoid deprecation message.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent point, patching and pushing.

@JeffBezanson
Copy link
Sponsor Member

The reason I didn't add this one is that it's too slow. I only wanted the iterators that are basically trivial wrappers, so that there's no overhead over writing the code some other way.

@ghost
Copy link
Author

ghost commented Jun 24, 2015

Maybe there is an issue in how I approach problems, a part of me where what is "Pythonic" needs to be stomped out. What I generally use chain for is when I have several collections, say strings from different files, that I need to apply some operation to, such as collecting statistics, yet I need to store them separately in memory. This usually happens during preprocessing, so optimal performance is not that much of an issue. Maybe what I should do is just create a mutating function instead. My apologies for mentioning this on the issue tracker, this may be taking a bit of a "julia-users" turn.

@stevengj
Copy link
Member

stevengj commented Jul 1, 2015

If something like this is included, it seems like it should accept an iterator of iterators, not just a Vector, as discussed in JuliaCollections/Iterators.jl#50; maybe it should go into the Iterators package, though.

@Keno
Copy link
Member

Keno commented Jan 7, 2018

The Flatten iterator with this functionality is in Base now.

@Keno Keno closed this Jan 7, 2018
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.

None yet

4 participants