Uniform random selection of a member of an list

    :param arr: list you want to select an element from
    :type arr: list
    :return: one element from the list
497651
def choice(self,arr):
    
    ind = self.randint(0,len(arr)-1)
    return arr[ind]
58674
def select(self, key=None, val=None, log='any', out=bool):
        
        assert out in [bool, int], "Arg out is not valid (int or bool) !"
        C0 = key is None or val is None
        if C0:
            if out is bool:
                ind = np.ones((self._nch,), dtype=bool)
            else:
                ind = np.arange(0, self._nch)
            return ind

        lt0 = [list, tuple, np.ndarray]
        lt1 = [str, int, float, np.int64, np.float64, bool]
        C0 = log in ['any', 'all']
        C1 = type(log) in lt0 and all([ll in ['any', 'all'] for ll in log])
        assert C0 or C1, "Arg out is not valid ('any','all' or an iterable) !"
        C2 = isinstance(key, str) and key in self._dchans.keys()
        assert C2, "Arg key not valid: provide key of self.dchans"
        C4 = type(val) in lt1
        C5 = type(val) in lt0 and all([type(vv) in lt1 for vv in val])
        assert C4 or C5, "Arg val not valid, should be in %s !"%str(lt1)
        if C4:
            val = [val]
        nv = len(val)
        ind = np.vstack([self._dchans[key] == vv for vv in val])
        if log == 'any':
            ind = np.any(ind,axis=0)
        else:
            ind = np.all(ind,axis=0)

        # To be finsihed: add operators and str operations + not

        return ind
234579
public static <T extends Comparable<? super T>>
    void quickSelect( T[] arr, int k )
    {
        quickSelect( arr, 0, arr.length - 1, k );
    }
140940
def insertion_sort(arr, simulation=False):
    
    
    iteration = 0
    if simulation:
        print("iteration",iteration,":",*arr)
        
    for i in range(len(arr)):
        cursor = arr[i]
        pos = i
        
        while pos > 0 and arr[pos - 1] > cursor:
            # Swap the number down the list
            arr[pos] = arr[pos - 1]
            pos = pos - 1
        # Break and do the final swap
        arr[pos] = cursor
        
        if simulation:
                iteration = iteration + 1
                print("iteration",iteration,":",*arr)

    return arr
186502
def join(self, *args):
        
        call_args = list(args)
        joiner = call_args.pop(0)
        self.random.shuffle(call_args)
        return joiner.join(call_args)
411495
def drop_empty(arr):
    
    return [x for x in arr if not isinstance(x, list) or len(x) > 0]
219587
def random_draw(self, size=None):
        
        return scipy.asarray([numpy.random.uniform(low=b[0], high=b[1], size=size) for b in self.bounds])
994971
function shuffleArray (options, arr) {
    if (!options.minify) { return undefined; }

    for (let i = 0, max = arr.length; i < max; i++) {
        let j = randomInt(max);

        if (arr[j] !== arr[i]) {
            let source = arr[i];

            arr[i] = arr[j];
            arr[j] = source;
        }
    }
}
1369590
public static function array_pop_rand(array &$arr) {
		$length = \count($arr);

		if (! $length) {
			return false;
		}

		// Nothing random about an array with one thing.
		if (1 === $length) {
			return static::array_pop_top($arr);
		}

		$keys = \array_keys($arr);
		$index = static::random_int(0, $length - 1);

		return $arr[$keys[$index]];
	}
1230448
def p_arr_assignment(p):
    
    i = 2 if p[1].upper() == 'LET' else 1
    id_ = p[i]
    arg_list = p[i + 1]
    expr = p[i + 3]

    p[0] = None
    if arg_list is None or expr is None:
        return  # There were errors

    entry = SYMBOL_TABLE.access_call(id_, p.lineno(i))
    if entry is None:
        return

    if entry.type_ == TYPE.string:
        variable = gl.SYMBOL_TABLE.access_array(id_, p.lineno(i))
        if len(variable.bounds) + 1 == len(arg_list):
            ss = arg_list.children.pop().value
            p[0] = make_array_substr_assign(p.lineno(i), id_, arg_list, (ss, ss), expr)
            return

    arr = make_array_access(id_, p.lineno(i), arg_list)
    if arr is None:
        return

    expr = make_typecast(arr.type_, expr, p.lineno(i))
    if entry is None:
        return

    p[0] = make_sentence('LETARRAY', arr, expr)
195884
def select_action(self, next_action_arr, next_q_arr):
        '''
        
        '''
        key_arr = self.select_action_key(next_action_arr, next_q_arr)
        return next_action_arr[key_arr], next_q_arr[key_arr]
882007
public static <T> T pickRandom (List<T> values)
    {
        int size = values.size();
        if (size == 0) {
            throw new IllegalArgumentException(
                "Must have at least one element [size=" + size + "]");
        }
        return values.get(getInt(size));
    }
1037889
def weighted_random_choice(items):
    
    l = list(items)
    r = random.random() * sum([i[1] for i in l])
    for x, p in l:
        if p > r:
            return x
        r -= p
    return None
963551
function (array) {
    var m = array.length, t, i;

    // While there remain elements to shuffle…
    while (m) {

      // Pick a remaining element…
      i = Math.floor(Math.random() * m--);

      // And swap it with the current element.
      t = array[m];
      array[m] = array[i];
      array[i] = t;
    }

    return array;
  }
21315
def bogo_sort(arr, simulation=False):
    
    
    iteration = 0
    if simulation:
        print("iteration",iteration,":",*arr)
    
    def is_sorted(arr):
        #check the array is inorder
        i = 0
        arr_len = len(arr)
        while i+1 < arr_len:
            if arr[i] > arr[i+1]:
                return False
            i += 1
            

        return True
    while not is_sorted(arr):
        random.shuffle(arr)
        
        if simulation:
            iteration = iteration + 1
            print("iteration",iteration,":",*arr)
            
    return arr
326965
function _removeArrayMember(arr, elem) {
		// TODO: use Array.indexOf for IE >= 9
		var i;
		for (i = arr.length - 1; i >= 0; i--) {
			if (arr[i] === elem) {
				arr.splice(i, 1);
				return true;
			}
		}
		return false;
	}
1064679
def p_let_arr_substr(p):
    
    i = 2 if p[1].upper() == 'LET' else 1

    id_ = p[i]
    arg_list = p[i + 1]
    substr = p[i + 2]
    expr_ = p[i + 4]
    p[0] = make_array_substr_assign(p.lineno(i), id_, arg_list, substr, expr_)