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

adds conversions from CartesianIndex to Number and Tuple #23795

Merged
merged 2 commits into from
Oct 1, 2017

Conversation

ssfrr
Copy link
Contributor

@ssfrr ssfrr commented Sep 20, 2017

@@ -1,7 +1,19 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Base.Test
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack, whoops, left this in from local testing. will fix momentarily

@@ -123,6 +123,10 @@ module IteratorsMD
_isless(ret, ::Tuple{}, ::Tuple{}) = ifelse(ret==1, true, false)
icmp(a, b) = ifelse(isless(a,b), 1, ifelse(a==b, 0, -1))

# conversions
convert(::Type{T}, index::CartesianIndex{1}) where {T<:Number} = convert(T, index[1])
convert(::Type{T}, index::CartesianIndex) where {T<:Tuple} = convert(T, index.I)
Copy link
Member

Choose a reason for hiding this comment

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

See also #23719

@mbauman
Copy link
Member

mbauman commented Sep 22, 2017

I think this is a nice follow-up to #23719 — both the constructor and conversion make sense here to me.

@KristofferC KristofferC merged commit eec8b76 into JuliaLang:master Oct 1, 2017
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