@@ -82,8 +82,8 @@ Delete the element at location `i` in `t`; if a list `I` of indices is specified
82
82
"""
83
83
deleteat (t:: Tuple , I:: Tuple{Int} ) = deleteat (t, I[1 ])
84
84
function 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 ))
87
87
end
88
88
deleteat (t:: Tuple , i:: Int ) = 1 <= i <= length (t) ? _deleteat (t, i) : throw (BoundsError (t, i))
89
89
@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
92
92
@inline _deleteat (t:: Tuple , I:: Tuple{Int} ) = _deleteat (t, I[1 ])
93
93
@inline _deleteat (t:: Tuple , I:: Tuple{Int,Int,Vararg{Int}} ) = _deleteat (_deleteat (t, I[1 ]), tail (I)) # assumes sorted from big to small
94
94
95
- ishift (t:: Tuple{Vararg{Int}} , i:: Int , s:: Int ) = map (n-> (n < i ? n : n+ s), t)
96
-
97
95
"""
98
96
insertat(t::Tuple, i::Int, t2::Tuple) -> ::Tuple
99
97
@@ -280,11 +278,13 @@ Computes a tuple that contains the permutation required to sort `t`.
280
278
end
281
279
end
282
280
r = _sortperm (_deleteat (t, i), lt, by, rev)
283
- return (i, ishift (r, i, + 1 )... )
281
+ return (i, _ishift (r, i, + 1 )... )
284
282
end
285
283
@inline _sortperm (t:: Tuple{Any} , lt= isless, by= identity, rev:: Bool = false ) = (1 ,)
286
284
@inline _sortperm (t:: Tuple{} , lt= isless, by= identity, rev:: Bool = false ) = ()
287
285
286
+ _ishift (t:: Tuple{Vararg{Int}} , i:: Int , s:: Int ) = map (n-> (n < i ? n : n+ s), t)
287
+
288
288
"""
289
289
getindices(t::Tuple, I::Tuple{Vararg{Int}}) -> ::Tuple
290
290
0 commit comments