23 July 2019, 09:42 Sebastian Gniazdowski wrote: > Turns out the expression can be simpler because the math mode within > array's index is implicit, so: > > idx=0; olen=$#a+1; a=( ${a[@]/(#m)*/$a[ ++idx % 2 ? olen : idx ]} ) > The expression can be even simpler if (valid in Zsh, just resolving to empty element when no ksharrays) index 0 will be used: idx=0; a=( ${a[@]/(#m)*/$a[ ++idx%2 ? 0 : idx ]} )