Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. using Base: @propagate_inbounds, tail
  2.  
  3. @propagate_inbounds function mygetindex(a::AbstractArray{T}, inds::StaticVector{<:Integer}) where {T}
  4. similar_type(a, T, Size(inds))(extract_values(a, inds.data))
  5. end
  6.  
  7. @propagate_inbounds extract_values(a, inds) = (a[inds[1]], extract_values(a, tail(inds))...)
  8. extract_values(a, ::Tuple{}) = ()
  9.  
  10. g(v) = @inbounds return mygetindex(v, v)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement