public static void Run() { { // IObservable<TSource> Aggregate<TSource>( // this IObservable<TSource> source, // Func<TSource, TSource, TSource> accumulator) var numbers = Observable.Range(0, 10); var sum = numbers.Aggregate(0, (acc, currentValue) => acc + currentValue); sum.Dump("sum"); // problem // 1. must be same type, 2. need at least one value } { // IObservable<TAccumulate> Aggregate<TSource, TAccumulate>( // this IObservable<TSource> source, // TAccumulate seed, // Func<TAccumulate, TSource, TAccumulate> accumulator) var chars = new Char[] { 'a', 'b', 'c' }.ToObservable(); var count = chars.Aggregate(0, (acc, _) => acc + 1); count.Dump("count"); } { // var numbers = new Subject<int>(); var scan = numbers.Scan(0, (acc, current) => acc + current); numbers.Dump("numbers"); scan.Dump("scan"); numbers.OnNext(1); numbers.OnNext(2); numbers.OnNext(3); numbers.OnCompleted(); // source.Aggregate(0, (acc, current) => acc + current); // is equivalent to // source.Scan(0, (acc, current) => acc + current).TakeLast(); } }