Convert an iterable value to an array with consecutive integer indexes

- if the value is already an array, only its values will be returned (keys are discarded)
- if the value is traversable, all its values will be returned
10858
static function toList(iterable $iterable): array
    {
        return $iterable instanceof \Traversable ? iterator_to_array($iterable, false) : array_values($iterable);
    }
543444
def each
      index = 0
      while index < i_keys.get_length
        key = i_keys.get(index)
        value = i_values.get(index)
        yield key , value
        index = index + 1
      end
      self
    end
161184
public static function toArray($value)
    {
        if (is_array($value)) {
            return $value;
        }

        if ($value === null) {
            return [];
        }

        if (!$value instanceof Traversable) {
            throw new Exception\InvalidArgumentException(
                'An invalid value was provided, should either be an null, array or Traversable'
            );
        }

        return iterator_to_array($value);
    }
1118659
function(arr, iterator) {
  var i = arr.length - 1, index = null

  if(i >= 0){
    do {
      if(iterator(arr[i])) {
        index = i
        break
      }
    } while(i--)
  }

  return index
}
186165
def map_recursive(function, iterable):
    
    if isiterable(iterable):
        dataOut = iterable.__class__()
        for i in iterable:
            if isinstance(dataOut, dict):
                dataOut[i] = map_recursive(function, iterable[i])
            else:
                # convert to list and append
                if not isinstance(dataOut, list):
                    dataOut = list(dataOut)
                dataOut.append(map_recursive(function, i))
        return dataOut
    return function(iterable)
499098
public static function iterableToArray($iterable): array
    {
        if (is_array($iterable)) {
            return $iterable;
        }

        if ($iterable instanceof \Traversable) {
            return iterator_to_array($iterable);
        }

        throw new \InvalidArgumentException('Iterable is expected.');
    }
1227971
def make_iterable(obj, default=None):
    
    if obj is None:
        return default or []
    if isinstance(obj, (compat.string_types, compat.integer_types)):
        return [obj]
    return obj
976058
def to_iter(obj):
    
    if isinstance(obj, type(None)):
        return None
    elif isinstance(obj, six.string_types):
        return [obj]
    else:
        # Nesting here since symmetry is broken in isinstance checks.
        # Strings are iterables in python 3, so the relative order of if statements is important.
        if isinstance(obj, collections.Iterable):
            return obj
        else:
            return [obj]
72564
public static <T> Map<Integer, T> fromIterable(
        Iterable<? extends T> iterable)
    {
        Map<Integer, T> map = new LinkedHashMap<Integer, T>();
        int i = 0;
        for (T t : iterable)
        {
            map.put(i, t);
            i++;
        }
        return map;
    }
248179
def get_keys_from_value(self, value):
        

        return [key for key, data in self.iteritems() if data == value]
162673
public static <T> ImmutableMultimap<T, Integer> itemToIndexMultimap(
      Iterable<T> iterable) {
    final ImmutableMultimap.Builder<T, Integer> ret = ImmutableMultimap.builder();
    int idx = 0;
    for (final T x : iterable) {
      ret.put(x, idx++);
    }
    return ret.build();
  }
497001
function toIterable(value) {
      if (value == null) {
        return [];
      }
      if (!isArrayLike(value)) {
        return values(value);
      }
      if (lodash.support.unindexedChars && isString(value)) {
        return value.split('');
      }
      return isObject(value) ? value : Object(value);
    }
488731
@SuppressWarnings("unchecked")
    public static <E> E[] toArray(final Iterable<E> iterable) {
        return (E[]) newArrayList(iterable).toArray();
    }
1371340
function map(arr, iterator) {
    var result = [], i;
    if (Array.prototype.map) {
      return Array.prototype.map.call(arr, iterator);
    }
    for (i = 0; i < arr.length; i++) {
      result.push(iterator(arr[i]));
    }
    return result;
  }
769220
function(obj) {

    var __p = 'var index, iterable = ' +
    (obj.firstArg) +
    ', result = ' +
    (obj.init) +
    ';\nif (!iterable) return result;\n' +
    (obj.top) +
    ';';
     if (obj.array) {
    __p += '\nvar length = iterable.length; index = -1;\nif (' +
    (obj.array) +
    ') {  ';
     if (support.unindexedChars) {
    __p += '\n  if (isString(iterable)) {\n    iterable = iterable.split(\'\')\n  }  ';
     }
    __p += '\n  while (++index < length) {\n    ' +
    (obj.loop) +
    ';\n  }\n}\nelse {  ';
     } else if (support.nonEnumArgs) {
    __p += '\n  var length = iterable.length; index = -1;\n  if (length && isArguments(iterable)) {\n    while (++index < length) {\n      index += \'\';\n      ' +
    (obj.loop) +
    ';\n    }\n  } else {  ';
     }

     if (support.enumPrototypes) {
    __p += '\n  var skipProto = typeof iterable == \'function\';\n  ';
     }

     if (support.enumErrorProps) {
    __p += '\n  var skipErrorProps = iterable === errorProto || iterable instanceof Error;\n  ';
     }

        var conditions = [];    if (support.enumPrototypes) { conditions.push('!(skipProto && index == "prototype")'); }    if (support.enumErrorProps)  { conditions.push('!(skipErrorProps && (index == "message" || index == "name"))'); }

     if (obj.useHas && obj.useKeys) {
    __p += '\n  var ownIndex = -1,\n      ownProps = objectTypes[typeof iterable] && keys(iterable),\n      length = ownProps ? ownProps.length : 0;\n\n  while (++ownIndex < length) {\n    index = ownProps[ownIndex];\n';
        if (conditions.length) {
    __p += '    if (' +
    (conditions.join(' && ')) +
    ') {\n  ';
     }
    __p += 
    (obj.loop) +
    ';    ';
     if (conditions.length) {
    __p += '\n    }';
     }
    __p += '\n  }  ';
     } else {
    __p += '\n  for (index in iterable) {\n';
        if (obj.useHas) { conditions.push("hasOwnProperty.call(iterable, index)"); }    if (conditions.length) {
    __p += '    if (' +
    (conditions.join(' && ')) +
    ') {\n  ';
     }
    __p += 
    (obj.loop) +
    ';    ';
     if (conditions.length) {
    __p += '\n    }';
     }
    __p += '\n  }    ';
     if (support.nonEnumShadows) {
    __p += '\n\n  if (iterable !== objectProto) {\n    var ctor = iterable.constructor,\n        isProto = iterable === (ctor && ctor.prototype),\n        className = iterable === stringProto ? stringClass : iterable === errorProto ? errorClass : toString.call(iterable),\n        nonEnum = nonEnumProps[className];\n      ';
     for (k = 0; k < 7; k++) {
    __p += '\n    index = \'' +
    (obj.shadowedProps[k]) +
    '\';\n    if ((!(isProto && nonEnum[index]) && hasOwnProperty.call(iterable, index))';
            if (!obj.useHas) {
    __p += ' || (!nonEnum[index] && iterable[index] !== objectProto[index])';
     }
    __p += ') {\n      ' +
    (obj.loop) +
    ';\n    }      ';
     }
    __p += '\n  }    ';
     }

     }

     if (obj.array || support.nonEnumArgs) {
    __p += '\n}';
     }
    __p += 
    (obj.bottom) +
    ';\nreturn result';

    return __p
  }
1258151
function all(iterable){
      var C      = getConstructor(this)
        , values = [];
      return new C(function(res, rej){
        forOf(iterable, false, values.push, values);
        var remaining = values.length
          , results   = Array(remaining);
        if(remaining)$.each.call(values, function(promise, index){
          C.resolve(promise).then(function(value){
            results[index] = value;
            --remaining || res(results);
          }, rej);
        });
        else res(results);
      });
    }
507150
function (len, val) {
			var array = [];
			var i = 0;
			while (i < len) {
				array[i++] = val;
			}
			return array;
		}