Fills array using specified values.
Can optionally pass in start and index of array to fill.
Default startIndex = 0. Default endIndex = length of array.
435877
function fill(list, value, startIndex=0, endIndex=list.length){
    if (!(list && Array.isArray(list))) {
      // Manually currying
      let args = arguments;
      return (list) => fill(list, ...args);
    }

    return Array(...list).map((x,i)=> {
      if(i>= startIndex && i <= endIndex) {
        return x=value;
      } else {
        return x;
      }
    });
  }
769829
public static <T> Ix<T> fromArray(T... values) {
        int n = values.length;
        if (n == 0) {
            return empty();
        }
        if (n == 1) {
            return just(values[0]);
        }
        return new IxFromArray<T>(0, values.length, values);
    }
1001426
@Override
    public void setArray(int parameterIndex, Array x) throws SQLException {
        internalStmt.setArray(parameterIndex, x);
    }
1325503
static MinMax minmax(int[] input, final int start, final int length) {
        int max = input[start];
        int min = max;
        for (int i = length - 2, index = start + 1; i >= 0; i--, index++) {
            final int v = input[index];
            if (v > max) {
                max = v;
            }
            if (v < min) {
                min = v;
            }
        }

        return new MinMax(min, max);
    }
441841
public static <T> T[] createArray(int size, T defaultValue) {
		T[] result = (T[]) GenericReflection.newArray(defaultValue.getClass(), size);
		for (int i = 0; i < result.length; i++) {
			result[i] = defaultValue;
		}
		return result;
	}
1164989
public static void fill(final Object[] array, final Object value) {
        //        final int n = array.length;
        //        if (n > 0) {
        //            array[0] = value;
        //        }
        //        for (int i = 1; i < n; i += i) {
        //           System.arraycopy(array, 0, array, i, ((n - i) < i) ? (n - i) : i);
        //        }
        for (int i=0; i<array.length; i++) {
            array[i] = value;
        }        
    }
735572
public static Object toPrimitiveLongArray(List<?> values)
    {
        long[] array = new long[values.size()];
        int cursor = 0;
        
        for(Object o : values)
        {
            array[cursor] = (Long) o;
            cursor ++;
        }
        return array;
    }
1305695
public static void fill(DMatrixD1 a, double value)
    {
        Arrays.fill(a.data, 0, a.getNumElements(), value);
    }
394275
public static void fill(GrayI16 input, int value) {

		for (int y = 0; y < input.height; y++) {
			int index = input.getStartIndex() + y * input.getStride();
			Arrays.fill(input.data,index,index+input.width, (short)value);
		}
	}
175053
public static void sort(double[] x, int start, int end)
    {
        int a = start;
        int n = end-start;
        if (n < 7)/* Insertion sort on smallest arrays */
        {
            insertionSort(x, a, end);
            return;
        }
        
        int pm = a + (n/2);  /* Small arrays, middle element */
        if (n > 7)
        {
            int pl = a;
            int pn = a + n - 1;
            if (n > 40) /* Big arrays, pseudomedian of 9 */
            {        
                int s = n / 8;
                pl = med3(x, pl, pl + s, pl + 2 * s);
                pm = med3(x, pm - s, pm, pm + s);
                pn = med3(x, pn - 2 * s, pn - s, pn);
            }
            pm = med3(x, pl, pm, pn); /* Mid-size, med of 3 */
        }
        double pivotValue = x[pm];

        int pa = a, pb = pa, pc = end - 1, pd = pc;
        while (true)
        {
            while (pb <= pc && x[pb] <= pivotValue)
            {
                if (x[pb] == pivotValue)
                    swap(x, pa++, pb);
                pb++;
            }
            while (pc >= pb && x[pc] >= pivotValue)
            {
                if (x[pc] == pivotValue)
                    swap(x, pc, pd--);
                pc--;
            }
            if (pb > pc)
                break;
            swap(x, pb++, pc--);
        }

        
        int s;
        int pn = end;
        s = Math.min(pa - a, pb - pa);
        vecswap(x, a, pb - s, s);
        s = Math.min(pd - pc, pn - pd - 1);
        vecswap(x, pb, pn - s, s);

        //recurse 
        if ((s = pb - pa) > 1)
            sort(x, a, a+s);
        if ((s = pd - pc) > 1)
            sort(x, pn - s, pn);
        
    }
625153
public static ValueArray createArray(int begin, int end, int step) {
        if (end < begin) {
            throw new IllegalArgumentException("End must be greater or equal to begin");
        }
        int nbClasses = (int) ((end - begin) / step);
        ValueInt[] getArray = new ValueInt[nbClasses];
        for (int i = 0; i < nbClasses; i++) {
            getArray[i] = ValueInt.get(i * step + begin);

        }        
        return ValueArray.get(getArray);
    }
528038
function fillArray(low, high, step, def) {
            step = step || 1;
            var i = [], x;
            for (x = low; x <= high; x += step) {
                i[x] = def === undefined ? x : (typeof def === 'function' ? def(x) : def);
            }
            return i;
        }
1234654
function arrayDefaults(arr, values) {
  values.forEach(function(x) {
    if (!~arr.indexOf(x)) arr.push(x)
  })
}
1282940
public static void fill(InterleavedI16 input, int value) {

		for (int y = 0; y < input.height; y++) {
			int index = input.getStartIndex() + y * input.getStride();
			int end = index + input.width*input.numBands;
			Arrays.fill(input.data,index,end, (short)value);
		}
	}
205989
public void fill(final double[][] data, final int startRow, final int startCol) {
		final int rows = data.length;
		final int cols = data[0].length;

		verifyTrue(startRow < rows && startRow < getRowCount(), "illegal startRow: %s", startRow);
		verifyTrue(startCol < cols && startCol < getColumnCount(), "illegal startCol: %s", startCol);
		verifyTrue(rows <= getRowCount(), "too many rows in input: %s: max allowed = %s", rows,
				getRowCount());
		verifyTrue(cols <= getColumnCount(), "too many columns in input: %s: max allowed = %s",
				cols, getColumnCount());

		for (int i = startRow; i < rows; i++) {
			for (int j = startCol; j < cols; j++) {
				setDouble(data[i][j], i, j);
			}
		}
	}
443606
public static Object toPrimitiveIntArray(List<?> values)
    {
        int[] array = new int[values.size()];
        int cursor = 0;
        
        for(Object o : values)
        {
            array[cursor] = (Integer) o;
            cursor ++;
        }
        return array;
    }
934144
public static <T extends Comparable<? super T>> 
    void insertionSort( T[] arr, int start, int end )
    {
        int i;
        for ( int j = start + 1; j <= end; j++ ) {
            T tmp = arr[j];
            for ( i = j; i > start && tmp.compareTo( arr[i - 1] ) < 0; i-- ) {
                arr[ i ] = arr[ i - 1 ];
            }
            if ( i < j ) arr[ i ] = tmp;
        }
    }