>>> from Redy.Collections import Traversal, Flow
    >>> def mul(a: int, b: int): return a * b
    >>> lst: Iterable[int] = [1, 2, 3]
    >>> x = Flow(lst)[Traversal.fold_by(mul, 1)].unbox
    >>> assert x is 6
765822
def fold_by(fn: Callable[[T1, T2], T1], start: T1) -> Callable[[ActualIterable[T2]], T1]:
    
    return lambda collection: functools.reduce(fn, collection, start)
1240586
def chunked(iterable, n):

    
    iterable = iter(iterable)
    while 1:
        t = tuple(islice(iterable, n))
        if t:
            yield t
        else:
            return
528537
def mul(a, b):
    
    if a is None:
        if b is None:
            return None
        else:
            return b
    elif b is None:
        return a
    return a * b
892562
def actually_flatten(iterable):
    """"""
    remainder = iter(iterable)
    while True:
        first = next(remainder)  # pylint: disable=R1708
        # Python 2/3 compat
        is_iter = isinstance(first, collections.Iterable)
        try:
            basestring
        except NameError:
            basestring = str  # pylint: disable=W0622

        if is_py3() and is_iter and not_a_string(first):
            remainder = IT.chain(first, remainder)
        elif (not is_py3()) and is_iter and not isinstance(first, basestring):
            remainder = IT.chain(first, remainder)
        else:
            yield polite_string(first)
602519
def mul_inv(a, b):
        
        b0 = b
        x0, x1 = 0, 1
        if b == 1:
            return 1
        while a > 1:
            q = a // b
            a, b = b, a % b
            x0, x1 = x1 - q * x0, x0
        if x1 < 0:
            x1 += b0
        return x1
954712
def call(cls, iterable, *a, **kw):
    

    return cls(x(*a, **kw) for x in iterable)
320441
def MUL(classical_reg, right):
    
    left, right = unpack_reg_val_pair(classical_reg, right)
    return ClassicalMul(left, right)
281632
public IVector mul(IVector a) {
        IVector result = new IVector(rows);
        mul(a, result);
        return result;
    }
819970
def ltake(n: int, xs: Iterable[T]) -> List[T]:
    
    return list(take(n, xs))
84312
function(a, b, retArr) {
            if (retArr) {
                return [a, b, a + b];
            }
            return a + b;
        }
160597
def iterslice(iterable, start=0, stop=None, step=1):
    # type: (Iterable[T], int, int, int) -> Iterable[T]
    

    if step < 0:
        raise ValueError("The step can not be negative: '%s' given" % step)

    if not isinstance(start, int):

        # [Callable:Callable]
        if not isinstance(stop, int) and stop:
            return stops_when(starts_when(iterable, start), stop)

        # [Callable:int]
        return starts_when(itertools.islice(iterable, None, stop, step), start)

    # [int:Callable]
    if not isinstance(stop, int) and stop:
        return stops_when(itertools.islice(iterable, start, None, step), stop)

    # [int:int]
    return itertools.islice(iterable, start, stop, step)
1163112
def window(iterable, size=2):
    '''  '''
    iterable = iter(iterable)
    d = deque(islice(iterable, size-1), maxlen=size)
    for _ in map(d.append, iterable):
        yield tuple(d)
178074
def compose(*fs: Any) -> Callable:
    
    return foldl1(lambda f, g: lambda *x: f(g(*x)), fs)
916930
def iterintervals(self, n=2):
        
        # tee the original iterator into n identical iterators
        streams = tee(iter(self), n)

        # advance the "cursor" on each iterator by an increasing
        # offset, e.g. if n=3:
        #
        #                   [a, b, c, d, e, f, ..., w, x, y, z]
        #  first cursor -->  *
        # second cursor -->     *
        #  third cursor -->        *
        for stream_index, stream in enumerate(streams):
            for i in range(stream_index):
                next(stream)

        # now, zip the offset streams back together to yield tuples,
        # in the n=3 example it would yield:
        # (a, b, c), (b, c, d), ..., (w, x, y), (x, y, z)
        for intervals in zip(*streams):
            yield intervals
943403
public static void fe_mul121666(int[] h,int[] f)
{
  int f0 = f[0];
  int f1 = f[1];
  int f2 = f[2];
  int f3 = f[3];
  int f4 = f[4];
  int f5 = f[5];
  int f6 = f[6];
  int f7 = f[7];
  int f8 = f[8];
  int f9 = f[9];
  long h0 = f0 * (long) 121666;
  long h1 = f1 * (long) 121666;
  long h2 = f2 * (long) 121666;
  long h3 = f3 * (long) 121666;
  long h4 = f4 * (long) 121666;
  long h5 = f5 * (long) 121666;
  long h6 = f6 * (long) 121666;
  long h7 = f7 * (long) 121666;
  long h8 = f8 * (long) 121666;
  long h9 = f9 * (long) 121666;
  long carry0;
  long carry1;
  long carry2;
  long carry3;
  long carry4;
  long carry5;
  long carry6;
  long carry7;
  long carry8;
  long carry9;

  carry9 = (h9 + (long) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25;
  carry1 = (h1 + (long) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25;
  carry3 = (h3 + (long) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25;
  carry5 = (h5 + (long) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25;
  carry7 = (h7 + (long) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25;

  carry0 = (h0 + (long) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
  carry2 = (h2 + (long) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26;
  carry4 = (h4 + (long) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
  carry6 = (h6 + (long) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
  carry8 = (h8 + (long) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;

  h[0] = (int)h0;
  h[1] = (int)h1;
  h[2] = (int)h2;
  h[3] = (int)h3;
  h[4] = (int)h4;
  h[5] = (int)h5;
  h[6] = (int)h6;
  h[7] = (int)h7;
  h[8] = (int)h8;
  h[9] = (int)h9;
}
1060760
def iter_chunks(l, size):
    
    if isinstance(l, six.integer_types):
        l = six.moves.range(l)

    if is_lazy_iterable(l):
        if size < 1:
            yield list(l)
        else:
            chunk = []
            for elem in l:
                if len(chunk) < size:
                    chunk.append(elem)
                else:
                    yield chunk
                    chunk = [elem]
            else:
                if chunk:
                    yield chunk

    else:
        if size < 1:
            yield l
        else:
            for i in six.moves.range(0, len(l), size):
                yield l[i:i + size]
1223849
def walk_recursive(f, data):
    
    results = {}
    if isinstance(data, list):
        return [walk_recursive(f, d) for d in data]
    elif isinstance(data, dict):
        results = funcy.walk_keys(f, data)

        for k, v in data.iteritems():
            if isinstance(v, dict):
                results[f(k)] = walk_recursive(f, v)
            elif isinstance(v, list):
                results[f(k)] = [walk_recursive(f, d) for d in v]
    else:
        return f(data)

    return results