ohm-softa/ohm-softa.github.io

13ln-fp2.md: comment says opposite of the code

Closed this issue · 0 comments

In the Right fold section, you have the following code implementing filter:

// retain all values less than 5
foldr(xs, List.<Integer>empty(), (z, zs) -> {
	if (z < 5) return zs;
	else return list(z, zs);
});
// 7

The code drops all z < 5 (and keeps values >= 5), but the comment in the first line says the opposite.

You never know when a comment was last adjusted to match the code, and of course the code always wins ;-) Therefore please change the comment to say _drop_ all values less than 5