//Maps the function FN to each element of array ARR, returning the
//results in a new array.  FN must be a function taking one argument
//and returning a value; if FN is called for side effects, it should
//still return null.  MAPLIST does not modify the input array.
function maplist(arr, fn) {

     var output = new Array();

     for (var i = 0; i < arr.length; i++) {

	  output[i] = fn(arr[i]);
     }

     return output;
}

Array.prototype.find = function(searchstr) {

     var returnarr = false;

     for (var i = 0; i < this.length; i++) {

	  if (typeof(searchstr) == 'function') {
	       
	       if (searchstr.test(this[i])) {

		    if (!returnarr) {
			 
			 returnarr = [];
		    }

		    returnarr.push(i);
	       }

	  } else {

	       if (this[i]===searchstr) {

		    if (!returnarr) { 

			 returnarr = []; 
		    }
		    
		    returnarr.push(i);
	       }
	  }
     }

     return returnarr;
}

