7 ms·
In Java it would look like this: List<Double> newshipping = oldshipping.stream().filter(i -> i % 2 == 1).map(i -> i + 0.5d).collect(Collectors.toList()); a bi
by fortpoint 11y ago
In Java it would look like this:
List<Double> newshipping = oldshipping.stream().filter(i -> i % 2 == 1).map(i -> i + 0.5d).collect(Collectors.toList());
a bit more verbose but the essential chaining idea is there...
- sk5t 11y agoThe above, only if you want to discard (filter) orders with an even number of things. Also I'm not sure about the use of floating point here...
- kilotaras 11y agoRuby's select[1] is the same as java 8's filter[2]. [1] http://ruby-doc.org/core-2.2.3/Enumerable.html#method-i-select http://ruby-doc.org/core-2.2.3/Enumerable.html#method-i-sele... [2] https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html#filter-java.util.function.Predicate- https://docs.oracle.com/javase/8/docs/api/java/util/stream/S...