Return the given amount of elements at random indices

@param {[any[], number]} params
@returns {any[]}
5749
function $rands(params) {
    if (
        Array.isArray(params) &&
        params.length === 2 &&
        Array.isArray(params[0]) &&
        typeof params[1] === 'number'
    ) {
        return Array(params[1])
            .fill()
            .map(() =>
                params[0].splice(
                    Math.floor(Math.random() * params[0].length),
                    1
                )
            )[0];
    }
    throw new Error(
        '$rands expects an array of two elements of which the first must be an array and the second be a number'
    );
}
457354
function getRandomArray (n) {
  var res = []
    , i, j, temp
    ;

  for (i = 0; i < n; i += 1) { res[i] = i; }

  for (i = n - 1; i >= 1; i -= 1) {
    j = Math.floor((i + 1) * Math.random());
    temp = res[i];
    res[i] = res[j];
    res[j] = temp;
  }

  return res;
}
1236243
function sample(collection) {
        var array = isArrayLike(collection) ? collection : values(collection), length = array.length;
        return length > 0 ? array[baseRandom(0, length - 1)] : undefined;
      }
727716
function random(min, max, float) {
  if (min === undefined) {
    return Math.random();
  }

  if (max === undefined) {
    max = min;
    min = 0;
  }

  if (max < min) {
    var tmp = max;
    max = min;
    min = tmp;
  }

  if (float) {
    var result = Math.random() * (max - min) + min;
    if (float === true) {
      return result;
    } else if (typeof float === 'number') {
      var str = result.toString();
      var index = str.indexOf('.');
      str = str.substr(0, index + 1 + float);
      if (str[str.length - 1] === '0') {
        str = str.substr(0, str.length - 1) + random(1, 9);
      }
      return parseFloat(str);
    }
  }

  return Math.floor(Math.random() * (max - min + 1) + min);
}
291013
function select(elems) {
	var r = Math.random();
	var ref = 0;

	for(var i=0; i < elems.length; i++) {
		var elem= elems[i];
		ref += elem[1];
		if (r < ref) return elem[0];
	}

	// This happens only if probabilities don't add up to 1
	return null;
}
1352761
function defineDagExtremity(params) {
  return function dagExtremityImpl(selector) {
    var eles = this;
    var ret = [];

    for (var i = 0; i < eles.length; i++) {
      var ele = eles[i];

      if (!ele.isNode()) {
        continue;
      }

      var disqualified = false;
      var edges = ele.connectedEdges();

      for (var j = 0; j < edges.length; j++) {
        var edge = edges[j];
        var src = edge.source();
        var tgt = edge.target();

        if (params.noIncomingEdges && tgt === ele && src !== ele || params.noOutgoingEdges && src === ele && tgt !== ele) {
          disqualified = true;
          break;
        }
      }

      if (!disqualified) {
        ret.push(ele);
      }
    }

    return this.spawn(ret, {
      unique: true
    }).filter(selector);
  };
}
1140052
function params(p) {

  var result = "";
  _.each(p, function (val) {
    result = result + spliter + val;
  });

  return result;
}
643213
function getRandomNumber(min, max) {
  return Math.round(Math.random() * (max - min) + min);
}
1251693
function randNum (n) {
  let sNum = ''
  for (let i = 0; i < n; i++) {
    sNum += tools.rnd(0, 9)
  }
  return sNum
}
374584
function(array, ind) {
    if (ind >= array.length || ind < 0) 
      throw new Error('$' + (ind + 1) + ': argument number out of range')
    return array[ind]
  }
679328
function (params, q) {
            q = q || new Query();

            if (params.sort) {
                this._parseSort(params.sort, q);
            }

            if (params.where) {
                this._parseCondition(params.where, q);
            }

            var undefined;
            if (params.limit !== undefined) {
                var limit = parseInt(params.limit, 10);
                if (!isNaN(limit)) {
                    q.limit(limit);
                }

            }

            if (params.offset !== undefined) {
                var offset = parseInt(params.offset, 10);
                if (!isNaN(offset)) {
                    q.offset(offset);
                }
            }

            return q;
        }
148270
def n_elements(self):
        
        if self.is_array:
            return functools.reduce(operator.mul, self.array_dimensions)
        else:
            return 1
994012
function getNth (elements, target) {
  var length = elements.length
  var count = 0
  for (var index = 0; index < length; index++) {
    var element = elements[index]
    if (!element.hasOwnProperty('deleted')) {
      if (count === target) {
        return index
      }
      count++
    }
  }
  return (index + 1)
}
1359276
function getNumElementsFromNonIndexedArrays(arrays) {
    var key = Object.keys(arrays)[0];
    var array = arrays[key];
    if (isArrayBuffer(array)) {
      return array.numElements;
    } else {
      return array.data.length / array.numComponents;
    }
  }
628060
public <T> T randomElement(List<T> elements) {
		return elements.get(randomBetween(0, elements.size() - 1));
	}
93195
function(values) {
          if (values.length < 2) {
            logger.tracef("Not enough to read (not array): %s", values);
            return undefined;
          }

          return {segments: values[0], count: values[1]}
        }
734021
function get(ids) {
		var els = [], el;

		if (o.typeOf(ids) !== 'array') {
			ids = [ids];
		}

		var i = ids.length;
		while (i--) {
			el = o.get(ids[i]);
			if (el) {
				els.push(el);
			}
		}

		return els.length ? els : null;
	}