3 ms·
Good advice about variable names (though surely "dentist" isn't all that obscure), but the example function suffers from the boilerplate that the author rightly
by jejones3141 10y ago
Good advice about variable names (though surely "dentist" isn't all that obscure), but the example function suffers from the boilerplate that the author rightly says is a problem. Looking at the Java Collection interface, the removeIf() description sounds like it actually modifies the Collection rather than creating a new one. Is there a way in Java to do the equivalent of the following Haskell (I'm being lazy and not writing a version for Traversable)
take n (filter (> 0) xs)
- lmm 10y agoYou can use the Java 8 streams interface, converting back and forth at the ends. Or there's a method in Guava-collections (won't be lazy though). Or you can use Scala.
- TheCoelacanth 10y agoIn Java it's `xs.stream().filter(x -> x > 0).limit(n)`. That's a fairly new API though, so it's not all that heavily used.