def interleave(*args):
    '''Interleaves the elements of the provided arrays.

        >>> a = [(0, 0), (1, 0), (2, 0), (3, 0)]
        >>> b = [(0, 0), (0, 1), (0, 2), (0, 3)]
        >>> interleave(a, b)
        [(0, 0, 0, 0), (1, 0, 0, 1), (2, 0, 0, 2), (3, 0, 0, 3)]

    This is useful for combining multiple vertex attributes into a single
    vertex buffer. The shader attributes can be assigned a slice of the
    vertex buffer.
    '''
    result = []
    for array in zip(*args):
        result.append(tuple(flatten(array)))
    return result
Interleaves the elements of the provided arrays.

        >>> a = [(0, 0), (1, 0), (2, 0), (3, 0)]
        >>> b = [(0, 0), (0, 1), (0, 2), (0, 3)]
        >>> interleave(a, b)
        [(0, 0, 0, 0), (1, 0, 0, 1), (2, 0, 0, 2), (3, 0, 0, 3)]

    This is useful for combining multiple vertex attributes into a single
    vertex buffer. The shader attributes can be assigned a slice of the
    vertex buffer.