I just finished delivering a talk at Oredev 2013 on better concurrency in Java 8. With Lambda
by smillies - 2013-11-27 03:51
Very nice - I like the step-by-step exposition. The thing I take with me is your warning "Unfortunately I fell victim to a slavish adherence to my requirements and all of the examples that re-enforced my boxed in thinking ...". Indeed, that happens to me too often.
With regard to your example, when one revisits the original imperative code, one sees that it does exactly what your final version does: iterate over the the lines, get a matcher for each line, disregard any non-matching lines, get the matched group as a double. It's a 1:1 correspondence, except the imperative version is inherently serial and less concise.
Had you not been misled by your "filter-first" expectation, you'd have been able to do that code transformation with ease, instead of taking such a circuitous route. (And we'd not have this most instructive blog post.)
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.