2 ms·
I'm not sure I get what's the difference between for example: def filterFilterTest (xs : Rep[Array[Int]]) : Rep[Int] = Stream[Int](xs) .f
by zokier 10y ago
I'm not sure I get what's the difference between for example:
def filterFilterTest (xs : Rep[Array[Int]]) : Rep[Int] =
Stream[Int](xs)
.filter(d => d % 2 == 0)
.filter(d => d % 3 == 0)
.fold(unit(0), ((a : Rep[Int]) => (b : Rep[Int]) => a + b))
and
xs.filter(d => d % 2 == 0).filter(d => d % 3 == 0).fold(0)(_+_)
(grabbed from unit tests here: https://github.com/strymonas/staged-streams.scala/blob/master/src/test/scala/StagedStreamSpec.scala#L143 https://github.com/strymonas/staged-streams.scala/blob/maste... )
They both look pretty much the same and superficially do the same thing too, so what makes this new thing better/novel?
- otini 10y agoI would say that the latter is non-optimal, i.e. generates some unnecessary intermediary values whereas the former is optimal as shown in the paper.