@Test public void tap() { MutableList<Integer> tapResult = Lists.mutable.of(); Interval interval = Interval.fromTo(10, -10).by(-5); LazyIterable<Integer> lazyTapIterable = interval.tap(tapResult::add); lazyTapIterable.each(x -> {}); // force evaluation Assert.assertEquals(interval, tapResult); }
@Test public void distinct() { LazyIterable<Integer> integers = Interval.oneTo(1000000000); Assert.assertEquals(FastList.newListWith(1, 2, 3, 4, 5), integers.distinct().take(5).toList()); LazyIterable<Integer> lazyInterval = Interval.oneTo(1000000).flatCollect(Interval::oneTo); LazyIterable<Integer> distinct = lazyInterval.distinct(); LazyIterable<Integer> take = distinct.take(5); Assert.assertEquals(Lists.immutable.of(1, 2, 3, 4, 5), take.toList()); }