Skip to content

adds conversions from CartesianIndex to Number and Tuple#23795

Merged
KristofferC merged 2 commits intoJuliaLang:masterfrom
ssfrr:cartesian_convert
Oct 1, 2017
Merged

adds conversions from CartesianIndex to Number and Tuple#23795
KristofferC merged 2 commits intoJuliaLang:masterfrom
ssfrr:cartesian_convert

Conversation

@ssfrr
Copy link
Copy Markdown
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
Copy Markdown
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


# 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
Copy Markdown
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
Copy Markdown
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