src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <R> Observable<R> scan(final R initialValue, BiFunction<R, ? super T, R> accumulator) {
        ObjectHelper.requireNonNull(initialValue, "initialValue is null");
        return scanWith(Functions.justCallable(initialValue), accumulator);
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <R> Observable<R> scan(final R initialValue, BiFunction<R, ? super T, R> accumulator) {
        ObjectHelper.requireNonNull(initialValue, "initialValue is null");
        return scanWith(Functions.justCallable(initialValue), accumulator);
    }
Returns an Observable that applies a specified accumulator function to the first item emitted by a source
ObservableSource and a seed value, then feeds the result of that function along with the second item emitted by
the source ObservableSource into the same function, and so on until all items have been emitted by the source
ObservableSource, emitting the result of each of these iterations.
<p>
<img width="640" height="320" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/scanSeed.png" alt="">
<p>
This sort of function is sometimes called an accumulator.
<p>
Note that the ObservableSource that results from this method will emit {@code initialValue} as its first
emitted item.
<p>
Note that the {@code initialValue} is shared among all subscribers to the resulting ObservableSource
and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer
the application of this operator via {@link #defer(Callable)}:
<pre><code>
ObservableSource&lt;T&gt; source = ...
Observable.defer(() -&gt; source.scan(new ArrayList&lt;&gt;(), (list, item) -&gt; list.add(item)));

// alternatively, by using compose to stay fluent

source.compose(o -&gt;
Observable.defer(() -&gt; o.scan(new ArrayList&lt;&gt;(), (list, item) -&gt; list.add(item)))
);
</code></pre>
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code scan} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>

@param <R> the initial, accumulator and result type
@param initialValue
the initial (seed) accumulator item
@param accumulator
an accumulator function to be invoked on each item emitted by the source ObservableSource, whose
result will be emitted to {@link Observer}s via {@link Observer#onNext onNext} and used in the
next accumulator call
@return an Observable that emits {@code initialValue} followed by the results of each call to the
accumulator function
@see <a href="http://reactivex.io/documentation/operators/scan.html">ReactiveX operators documentation: Scan</a>