Created
August 7, 2017 18:18
-
-
Save mschauer/c6285e4f509e48a0e13946ca113230fa to your computer and use it in GitHub Desktop.
Forget the shape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Base.Iterators | |
| import Base: done, next, start, length, eltype, iteratorsize, HasShape, HasLength | |
| struct UnshapedIterator{I} | |
| it::I | |
| UnshapedIterator{I}(it::I, a::HasShape) = new{I}(it) | |
| UnshapedIterator{I}(it::I, a::HasLength) = new{I}(it) | |
| end | |
| unshaped(it::I) where {I} = UnshapedIterator{I}(it, iteratorsize(it)) | |
| done(it::UnshapedIterator, s) = done(it.it, s) | |
| next(it::UnshapedIterator, s) = next(it.it, s) | |
| start(it::UnshapedIterator) = start(it.it) | |
| length(it::UnshapedIterator) = length(it.it) | |
| eltype(it::Type{UnshapedIterator}) = eltype(it.it) | |
| iteratorsize(::Type{<:UnshapedIterator}) = HasLength() | |
| unshaped(zip(1:3,1:4)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment