Ejemplo n.º 1
0
            private IEnumerator <object> Accumulator(CodeContext /*!*/ context, IEnumerator iterable, object function)
            {
                if (!MoveNextHelper(iterable))
                {
                    yield break;
                }

                object total = iterable.Current;

                yield return(total);

                if (function == null)
                {
                    PythonContext pc = context.LanguageContext;
                    while (MoveNextHelper(iterable))
                    {
                        total = pc.Add(total, iterable.Current);
                        yield return(total);
                    }
                }
                else
                {
                    while (MoveNextHelper(iterable))
                    {
                        total = PythonCalls.Call(function, total, iterable.Current);
                        yield return(total);
                    }
                }
            }