Well, It looks interesting, what exactly does it d...
# rx
g
Well, It looks interesting, what exactly does it do?
a
Scan method functions as documented here: http://reactivex.io/documentation/operators/scan.html My implementation is one which simply doesn’t rely on Rx: 1. I have a list of stuff [1, 2, 3, 4, 5] 2. If the list is empty, I simply return it. 3. Otherwise, we fold over the tail of the list, using a singleton list containing the first item as our start object. Each iteration of fn returns a list with all of acc plus the result of the latest object in acc, and the item, applied to fn. In the case of [1, 2, 3, 4, 5], fn = {x, y -> x + y}: We fold over: [1], [2, 3, 4, 5] Iter 1: acc = [1], item = 2, fn(acc.last(), item) = 3 Iter 2: acc = [1, 3] item = 3, fn(acc.last(), item) = 6 Iter 3: acc = [1, 3, 6] item = 4, fn(acc.last(), item) = 10 Iter 4: acc = [1, 3, 6, 10] item = 5, fn(acc.last(), item) = 15 result = [1, 3, 6, 10, 15]
g
I see, interesting
Thanks for the explanation