@@ -82,8 +82,8 @@ Delete the element at location `i` in `t`; if a list `I` of indices is specified
8282"""
8383deleteat (t:: Tuple , I:: Tuple{Int} ) = deleteat (t, I[1 ])
8484function deleteat (t:: Tuple , I:: Tuple{Int, Int, Vararg{Int}} )
85- any (i-> (1 <= i <= length (t)), I) && throw (BoundsError (t, I))
86- _deleteat (_deleteat ( t, I[ 1 ]), ishift ( tail (I), I[ 1 ], - 1 ))
85+ any (i-> ! (1 <= i <= length (t)), I) && throw (BoundsError (t, I))
86+ _deleteat (t, sort (I, rev = true ))
8787end
8888deleteat (t:: Tuple , i:: Int ) = 1 <= i <= length (t) ? _deleteat (t, i) : throw (BoundsError (t, i))
8989@inline _deleteat (t:: Tuple , i:: Int ) = i == 1 ? tail (t) : (t[1 ], _deleteat (tail (t), i- 1 )... )
@@ -92,8 +92,6 @@ deleteat(t::Tuple, i::Int) = 1 <= i <= length(t) ? _deleteat(t, i) : throw(Bound
9292@inline _deleteat (t:: Tuple , I:: Tuple{Int} ) = _deleteat (t, I[1 ])
9393@inline _deleteat (t:: Tuple , I:: Tuple{Int,Int,Vararg{Int}} ) = _deleteat (_deleteat (t, I[1 ]), tail (I)) # assumes sorted from big to small
9494
95- ishift (t:: Tuple{Vararg{Int}} , i:: Int , s:: Int ) = map (n-> (n < i ? n : n+ s), t)
96-
9795"""
9896 insertat(t::Tuple, i::Int, t2::Tuple) -> ::Tuple
9997
@@ -280,11 +278,13 @@ Computes a tuple that contains the permutation required to sort `t`.
280278 end
281279 end
282280 r = _sortperm (_deleteat (t, i), lt, by, rev)
283- return (i, ishift (r, i, + 1 )... )
281+ return (i, _ishift (r, i, + 1 )... )
284282end
285283@inline _sortperm (t:: Tuple{Any} , lt= isless, by= identity, rev:: Bool = false ) = (1 ,)
286284@inline _sortperm (t:: Tuple{} , lt= isless, by= identity, rev:: Bool = false ) = ()
287285
286+ _ishift (t:: Tuple{Vararg{Int}} , i:: Int , s:: Int ) = map (n-> (n < i ? n : n+ s), t)
287+
288288"""
289289 getindices(t::Tuple, I::Tuple{Vararg{Int}}) -> ::Tuple
290290
0 commit comments