Flatten a nested list.
550016
def flatten(l):
    """"""
    return sum(map(flatten, l), []) \
        if isinstance(l, list) or isinstance(l, tuple) else [l]
198059
def flatten(self, l):
        """"""
        if l == []:
            return l
        if isinstance(l[0], list):
            return self.flatten(l[0]) + self.flatten(l[1:])
        return l[:1] + self.flatten(l[1:])
1270590
def flatten(lol):
    
    new_list = []
    for element in lol:
        if element is None:
            continue
        elif not isinstance(element, list) and not isinstance(element, tuple):
            new_list.append(element)
        elif len(element) > 0:
            new_list.extend(flatten(element))
    return new_list
527485
def flatten(l: Iterable) -> List:
    
    rval = []
    for e in l:
        if not isinstance(e, str) and isinstance(e, Iterable):
            if len(list(e)):
                rval += flatten(e)
        else:
            rval.append(e)
    return rval
189075
def flatten(L):
    
    if not isinstance(L, list):
        return [L]

    if L == []:
        return L

    return flatten(L[0]) + flatten(L[1:])
538156
def flatten(cls, stats):
        """"""
        flat_children = {}
        for _stats in spread_stats(stats):
            key = (_stats.name, _stats.filename, _stats.lineno, _stats.module)
            try:
                flat_stats = flat_children[key]
            except KeyError:
                flat_stats = flat_children[key] = cls(*key)
            flat_stats.own_hits += _stats.own_hits
            flat_stats.deep_hits += _stats.deep_hits
            flat_stats.own_time += _stats.own_time
            flat_stats.deep_time += _stats.deep_time
        children = list(itervalues(flat_children))
        return cls(stats.name, stats.filename, stats.lineno, stats.module,
                   stats.own_hits, stats.deep_hits, stats.own_time,
                   stats.deep_time, children)
1359762
def flatten(iterable):
    """"""
    # likely not used
    iterable = iter(iterable)
    while True:
        try:
            item = next(iterable)
        except StopIteration:
            break

        if isinstance(item, six.string_types):
            yield item
            continue

        try:
            data = iter(item)
            iterable = itertools.chain(data, iterable)
        except:
            yield item
1006104
def flatten(struct):
    
    if struct is None:
        return []
    flat = []
    if isinstance(struct, dict):
        for key, result in struct.items():
            flat += flatten(result)
        return flat

    if isinstance(struct, basestring):
        return [struct]

    try:
        # if iterable
        for result in struct:
            flat += flatten(result)
        return flat
    except TypeError:
        pass

    return [struct]
1028604
def flatten(listish):
    
    for elem in listish:
        if (isinstance(elem, collections.Iterable)
                and not isinstance(elem, basestring)):
            for subelem in flatten(elem):
                yield subelem
        else:
            yield elem
524205
def flatten_array(grid):
    
    grid = [grid[i][j] for i in range(len(grid)) for j in range(len(grid[i]))]
    while type(grid[0]) is list:
        grid = flatten_array(grid)
    return grid
1195034
def flatten(iterable, check=is_iterable):
    
    for value in iterable:
        if check(value):
            for flat in flatten(value, check):
                yield flat
        else:
            yield value
782459
def flatten(self, shallow=None):
        
        return self._wrap(self._flatten(self.obj, shallow))
526883
def flatten(l):
    
    l = list(l)
    i = 0
    while i < len(l):
        while isinstance(l[i], list):
            if not l[i]:
                l.pop(i)
                i -= 1
                break
            else:
                l[i:i + 1] = l[i]
        i += 1
    return l
747241
def flatMap(f: Callable, xs: Iterable) -> List:
    
    return flatten(lmap(f, xs))
606680
function flatten(array, target) {
	const result = target || [];

	for (let i = 0; i < array.length; ++i) {
		if (Array.isArray(array[i])) {
			flatten(array[i], result);
		}
		else {
			result.push(array[i]);
		}
	}

	return result;
}
264012
def _flatten_list(self, data):
        ''

        if data is None:
            return ''
        if isinstance(data, types.StringTypes):
            return data
        elif isinstance(data, (list, tuple)):
            return '\n'.join(self._flatten_list(x) for x in data)
404737
def flatten_to(atom: Union[Tuple[Type[T]], Type[T]]):
    

    def inner(nested: ActualIterable[Union[T, ActualIterable[T]]]) -> ActualIterable[T]:
        for each in nested:
            if isinstance(each, atom):
                yield each
            else:
                yield from inner(each)

    return inner