Index of functions

I have spent a bit of time playing around with bash functions to manipulate arrays. There are functions that treat an array as a stack (e.g. pop and push); functions to add and remove any element; functions to move elements around, etc..

The important feature of these functions is that they are always passed the names of one or more arrays, never their elements.

They are also fully self-contained. Any function can be copied into a script without having to worry about dependencies.

The functions haven't been thoroughly tested (there's a framework for a test suite here), and they should have more documentation. I'd like to add some examples, but I don't know whether I'll spend any more time on either the functions or this section of my website.

The function library is released under the GNU General Public Licence.

Please leave comments on my blog.

lookup
Look up value in array and return index in variable
copy
Copy array to new array
fib
Add next number in fibonacci series to end of array
concat
Concatenate two arrays, store in third
rshove
Add element to end of array and remove first element
shove
Add element to beginning of array and remove last element
show_pairs
Pair corresponding elements of 2 arrays and print
show
Print, or store in variable, all elements of array
burst
Split string into array using SEP as delimiter
push
Add value[s] to beginning of array
pop
Remove top element (array[0]) from stack and place in varname
add_end
Add element to end of list
peek_end
Get element from end of list
pop_end
Remove element from end of list and store in varname
dup
Duplicate top item on stack
peek
Store top element of array in variable, but do not remove it
exch
Exchange top two elements on stack
reverse
Reverse order of array
string2array
Split string into array of characters
move
Move element to right or left
insert
Insert element into array at position
remove
Remove element from array
roll
Rotate top N elements; [N] moves to [0] with optional repeat
rolr
Rotate top N elements; [0] moves to [N] with optional repeat
rotate
Move element from one end of the array to the other with optional repeat
duplicate
Create a copy of an array
pair
Pair corresponding elements of 2 arrays to single element in new array
merge
Merge 2 arrays
mergex
Merge 2 arrays including unset elements
compact
Remove unset elements holding a place in array
add
Pop two elements, add them, leave result on top of stack and in varname
sub
Pop two elements, subtract, leave result on top of stack and in varname
mean
Average integer elements in array
total
Add all numerical elements of array
count
Return number of elements in array
forall
Perform action on each element of the array
longest
Find the longest element (most characters)
shortest
Find the shortest element (fewest characters)
max
Find the element with the highest value (text or numeric)
min
Find the element with the lowest value (text or numeric)
array-funcs file
The whole kit and kaboodle