coerce ranges, integers and array in appropriate ways
767616
def coerce_positions *positions
      if positions.size == 1
        case positions.first
        when Integer
          positions.first
        when Range
          size.times.to_a[positions.first]
        else
          raise ArgumentError, 'Unkown position type.'
        end
      else
        positions
      end
    end
138753
function(input, shallow, strict, startIndex) {
                var output = [], idx = 0;
                for (var i = startIndex || 0, length = getLength(input); i < length; i++) {
                  var value = input[i];
                  if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
                    //flatten current level of array or arguments object
                    if (!shallow) value = flatten(value, shallow, strict);
                    var j = 0, len = value.length;
                    output.length += len;
                    while (j < len) {
                      output[idx++] = value[j++];
                    }
                  } else if (!strict) {
                    output[idx++] = value;
                  }
                }
                return output;
              }
1258756
def parse_range_list(ranges):
    
    if not ranges:
        return []
    parts = ranges.split(',')
    out = []
    for part in parts:
        fields = part.split('-', 1)
        if len(fields) == 2:
            start = int(fields[0])
            end = int(fields[1])
            out.extend(range(start, end + 1))
        else:
            out.append(int(fields[0]))
    return out
62948
def parse_range_pairs(s, range_separator = '-', convert_to_tuple = True):
    ''' 
    '''
    result = map(sorted,
       map(lambda r:
            (int(r.split(range_separator)[0]), int(r.split(range_separator)[1])) if range_separator in r
            else (int(r), int(r)),
            s.split(',')))
    if convert_to_tuple:
        return tuple(map(tuple, result))
    return result
1327023
def MakeRanges(codes):
  """"""
  ranges = []
  last = -100
  for c in codes:
    if c == last+1:
      ranges[-1][1] = c
    else:
      ranges.append([c, c])
    last = c
  return ranges
371689
function(array, pred) {
      if (!isSeq(array)) throw new TypeError;

      var sz = _.size(array);

      for (var index = 0; index < sz; index++) {
        if(!truthy(pred(array[index]))) {
          break;
        }
      }

      return _.take(array, index);
    }
1053513
function coalesce(ranges) {
  if (!ranges.length) return [];
  var results=[ranges[0]];
  ranges.reduce(function (a,b) {
    var prev=results.length-1;
    if (a[a.length-1]===pred(b[0])) {
      return results[prev]=results[prev][0]+b[b.length-1];
    }
    results.push(b);
    return b;
  });
  return results.reduce(function (results,range) {
    if (range.length===2 && range[0]===pred(range[1])) {
      results.push(range[0]);
      results.push(range[1]);
    } else {
      results.push(range);
    }
    return results;
  },[]);
}
1337863
function rangeFromIndexAndOffsets(i, before, after, length) {
  return {
    // Guard against the negative upper bound for lines included in the output.
    from: i - before > 0 ? i - before : 0,
    to: i + after > length ? length : i + after
  };
}
907740
def _check_range(range_):
        """"""
        try:
            if not isinstance(range_, list):
                range_ = list(range_)
            min_, max_ = range_
        except (ValueError, TypeError):
            raise TypeError("each range in ising_linear_ranges should be a list of length 2.")
        if not isinstance(min_, Number) or not isinstance(max_, Number) or min_ > max_:
            raise ValueError(("each range in ising_linear_ranges should be a 2-tuple "
                              "(min, max) where min <= max"))
        return range_
106536
def vectorize_range(values):
    
    if isinstance(values, tuple):
        return '_'.join(str(i) for i in values)
    if isinstance(values, list):
        if not all([isinstance(item, tuple) for item in values]):
            raise TypeError('Items in the list must be tuples')
        return ','.join('_'.join(str(i) for i in v) for v in values)
    return str(values)
1032182
function range(defaultMin, defaultMax, min, max) {
  if (min === undefined) {
    return integer(defaultMin, defaultMax); // ()
  }

  if (max === undefined) {
    return min; // ( len )
  }

  return integer(min, max); // ( min, max )
}
565908
public static int[] range(int start, int end) {
    int[] out = new int[end - start];
    for(int i = 0, j = start; j < end; i++, j++) {
      out[i] = j;
    }
    return out;
  }
867455
def intranges_contain(int_, ranges):
    """"""
    tuple_ = _encode_range(int_, 0)
    pos = bisect.bisect_left(ranges, tuple_)
    # we could be immediately ahead of a tuple (start, end)
    # with start < int_ <= end
    if pos > 0:
        left, right = _decode_range(ranges[pos-1])
        if left <= int_ < right:
            return True
    # or we could be immediately behind a tuple (int_, end)
    if pos < len(ranges):
        left, _ = _decode_range(ranges[pos])
        if left == int_:
            return True
    return False
644038
function rangesIntersect(rangeA, rangeB) {
  return rangeA.compareBoundaryPoints(Range.END_TO_START, rangeB) === -1 &&
    rangeA.compareBoundaryPoints(Range.START_TO_END, rangeB) === 1
}
540540
def restrict(value, range)
      [[value, range.first].max, range.last].min
    end
353338
function range( arr, clbk ) {
	if ( !isArray( arr ) ) {
		throw new TypeError( 'range()::invalid input argument. Must provide an array. Value: `' + arr + '`.' );
	}

	if ( arguments.length > 1 && !isFunction( clbk ) ) {
		throw new TypeError( 'range()::invalid input argument. Accessor must be a function. Value: `' + clbk + '`.' );
	}
	var len = arr.length,
		min,
		max,
		x, i;

	if ( len === 0 ) {
		return null;
	}
	if ( clbk ) {
		min = clbk( arr[ 0 ] );
		max = min;
		for ( i = 1; i < len; i++ ) {
			x = clbk( arr[ i ] );
			if ( x < min ) {
				min = x;
			} else if ( x > max ) {
				max = x;
			}
		}
	} else {
		min = arr[ 0 ];
		max = min;
		for ( i = 1; i < len; i++ ) {
			x = arr[ i ];
			if ( x < min ) {
				min = x;
			} else if ( x > max ) {
				max = x;
			}
		}
	}
	return [ min, max ];
}
373271
def _fix_range(self, num, isslice=True):
        

        nrows = self._info['nrows']
        if isslice:
            # include the end
            if num < 0:
                num = nrows + (1+num)
            elif num > nrows:
                num = nrows
        else:
            # single element
            if num < 0:
                num = nrows + num
            elif num > (nrows-1):
                num = nrows-1

        return num