Functional Programming in Java, Second Edition (Pragmatic Bookshelf)
Latest Threads About This Book
@venkats
Appears to be a broken link in Appendix 3 a(Web Resources) on Page 234, for article to “Tell, Don’t Ask”.
Link goes to: https:...
New
@venkats
In the section “Iterating a String” found in chapter 3 “Strings, Comparators, and Filters” there seems to be a typo:
“But we w...
New
Nothing surprising here, just adapting the form to the other examples.
Ah yes, compute() now returns an immutable list in all cases.
pa...
New
As usual, but the original code to be refactored was just too evil and had to be fixed.
package chapter11;
import org.junit.jupiter.api...
New
In this code:
We actually create the (temporary) file we want to read and delete it again at the end.
Default charsets for reading text...
New
The usual changes but:
The “FirstRepeatedLetter.findIn()” has been improved out of the box. In particular returning ‘\0’ is too C-like ...
New
Nothing special here, same changes as formerly, but we are using people.isEmpty() instead of people.size() == 0 for even better legibilit...
New
The same remarks apply as for “Refactoring the Traditional for Loop”
No init()
Negative tests which apply for input less than 1900, res...
New
The same remarks apply as for “Refactoring the Traditional for Loop”
No init()
Classes under test implement a common interface that is...
New
Suggestions for some JUnit test improvements in Refactoring the Traditional “for” loop p 181 ff
Below code for testing the original/cla...
New
Although now aged by 34 years:
“The Conception, Evolution, and Application of Functional Programming Languages”
by Paul Hudak (1989-09-...
New
On page 15, we read:
In this example we’re sending a function, price -> price * 0.9, as an argument to mapToDouble The function bein...
New
In Chapter 9, p.164 the stream is parallelized in 1 step.
This inspired my to write some test some code to call a task “in parallel”:
...
New
On page 179:
First, imperative style was the way of life in Java and most programmers are very familiar with that style, since that was...
New
As traditional , the “impure” code of page 207 in the form of a pretend test.
(Doesn’t “impure” refer to performing uncontrolled side ef...
New
A question to highlight is:
Is there a way to make sure that a stream is NOT parallel, and make this evident in the code?
As in:
strea...
New
I have been thinking about how to collect “two adjacent elements” in a stream, for example transform a stream of Long into a stream of Pa...
New
On page 200, the code can use boxed() instead of the (somewhat mysterious) maptoObject(e -> e)
One should also reveal to the reader t...
New
One should refer the user to the official java.util.stream package (Stream API) documentation.
First appearance of the API in Java 8 (Ma...
New
Joe asks: Are stream pipelines the same as ‘RxJava’
Not quite. Although Java 8 Streams and RxJava (“Reactive Extensions in Java”) are bo...
New
On page 174:
StreamAPI
Should probably be
Stream API
Also on page 174:
blow up with an exception
Suggesting to change this wh...
New
It turns out that Try<T> can be ameliorated by judicious application of subclassing: no need to distinguish by actual type in the s...
New
As for FinanceData on page 91, the code for AirportInfo uses the suspect and soon-to-be-deprecated java.net.URL. Let’s use java.net.URI i...
New
Just some thoughts on being hard on exceptions in functional languages.
On p. 167 we read:
Functional style code is amazing, concise, ...
New
We read:
We are using the amazing feature of the switch expression of Java [Java 12]. If you’re using an older version of Java, you may...
New
All the code for Chapter 8, Using Tail-Call Optimization, in one class. But without the part where we later need to “fix the arithmetic o...
New
On p.27, after “Found 2 names”, we read:
The filter() method returns an iterator just like the map() method does,
But it really return...
New
The filter stream operation appears on several places in Chapter 2 and Chapter 3, so it’s difficult to say where to put this, but there s...
New
SimpleTimer.java
package chapter7;
import java.util.function.Supplier;
public abstract class SimpleTimer {
public record Result<...
New
Nothing special:
package chapter7;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.function.Supplier;
impor...
New
Most Active This Week
Most Active This Month
Most Active This Year
Most Active Last Three Years
@venkats
On page 21:
For each price from the prices list that passes through the filter(), the mapToInt() method invokes the provided ...
New
On p.27, after “Found 2 names”, we read:
The filter() method returns an iterator just like the map() method does,
But it really return...
New
On page 91, we use a short method to request a stock ticker, class FinanceData
However, this method is based on java.net.URL which has a...
New
We read:
Recursion is a powerful and charming way to solve problems. It’s highly expressive—using recursion we can provide a solution t...
New
In several places, the method
String.toUpperCase()
is misspelled as
String.toUppercase()
sometimes via the :: method reference,
Stri...
New
We find this code on page 61, for ListSelectFiles.java
final String[] files =
new File("fpij").list(new java.io.FilenameFilter()...
New
Just some thoughts on being hard on exceptions in functional languages.
On p. 167 we read:
Functional style code is amazing, concise, ...
New
@venkats
At 2/3rd of the page, we read;
Within the computeMaxProfit() method, we perform our task, and when it’s time to recurse we ro...
New
On page 148, “An optimization problem” we read:
We’ll employ a solution for a company that buys rods at wholesale and sells them at reta...
New
As for FinanceData on page 91, the code for AirportInfo uses the suspect and soon-to-be-deprecated java.net.URL. Let’s use java.net.URI i...
New
As previously, the code uses
List<String> names = Arrays.asList(...);
which yields an “array-backed list”, rather than
List<S...
New
On page 174:
StreamAPI
Should probably be
Stream API
Also on page 174:
blow up with an exception
Suggesting to change this wh...
New
On page 90, CalculateNAVTest.java:
public class CalculateNAVTest {
@Test
public void computeStockWorth() {
final CalculateN...
New
I have been thinking about how to collect “two adjacent elements” in a stream, for example transform a stream of Long into a stream of Pa...
New
Nothing surprising here, just adapting the form to the other examples.
Ah yes, compute() now returns an immutable list in all cases.
pa...
New
Most Active Over Three Years
Learn and apply the powerful streams API and lambda expressions to create highly expressive, concise, and maintainable functional style c...
New
It turns out that Try<T> can be ameliorated by judicious application of subclassing: no need to distinguish by actual type in the s...
New
Suggestions for some JUnit test improvements in Refactoring the Traditional “for” loop p 181 ff
Below code for testing the original/cla...
New
@venkats
In the section “Iterating a String” found in chapter 3 “Strings, Comparators, and Filters” there seems to be a typo:
“But we w...
New
The filter stream operation appears on several places in Chapter 2 and Chapter 3, so it’s difficult to say where to put this, but there s...
New
@venkats
Appears to be a broken link in Appendix 3 a(Web Resources) on Page 234, for article to “Tell, Don’t Ask”.
Link goes to: https:...
New
We read:
We are using the amazing feature of the switch expression of Java [Java 12]. If you’re using an older version of Java, you may...
New
A question to highlight is:
Is there a way to make sure that a stream is NOT parallel, and make this evident in the code?
As in:
strea...
New
As traditional , the “impure” code of page 207 in the form of a pretend test.
(Doesn’t “impure” refer to performing uncontrolled side ef...
New
Nothing special here, same changes as formerly, but we are using people.isEmpty() instead of people.size() == 0 for even better legibilit...
New
Although now aged by 34 years:
“The Conception, Evolution, and Application of Functional Programming Languages”
by Paul Hudak (1989-09-...
New
The same remarks apply as for “Refactoring the Traditional for Loop”
No init()
Negative tests which apply for input less than 1900, res...
New
As usual, but the original code to be refactored was just too evil and had to be fixed.
package chapter11;
import org.junit.jupiter.api...
New
The same remarks apply as for “Refactoring the Traditional for Loop”
No init()
Classes under test implement a common interface that is...
New
I had real trouble understanding the “memoizer”, I suppose Java syntax does not help in thinking about what should be a one-liner in Lamb...
New
Publisher:
Pragmatic Bookshelf
Latest in Functional Programming in Java, Second Edition
Get money off!
The Pragmatic Bookshelf
35% off any eBook
Use the coupon code "devtalk.com" to get 35% off any eBook published by PragProg!







