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...
The 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...
Re:How to Pass a Programming Interview
by kilotaras on Wednesday March 09, 2016 @05:41AM
(#11252122)
Ruby'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-sele... [2] https://docs.oracle.com/javase/8/docs/api/java/util/stream/S...
newshipping = oldshipping.select{|i| i % 2 == 1 }.map{|i| i + 0.5 }
My ridiculous fictional writing about shipping widgets is way more confusing than the idea that you can select and then chain right into a map.
This probably looks really weird to a java guy but its not really all that mysterious. I wonder what that looks like in Java.