StreamToLoop tests grouped

This commit is contained in:
Tagir Valeev
2017-01-27 17:38:37 +07:00
parent babce0b78c
commit fb6ba726e5
307 changed files with 2749 additions and 4686 deletions

View File

@@ -1,4 +1,4 @@
// "Replace Stream API chain with loop" "true"
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
import java.util.stream.IntStream;
@@ -7,7 +7,12 @@ public class Main {
return IntStream.range(start, stop).mapToDouble(x -> 1.0 / x).filter(x -> x < v).cou<caret>nt();
}
private static long checkClosed(int start, double val) {
return IntStream.rangeClosed(start, start*200).mapToDouble(x -> 1.0 / x).filter(v -> v < val).count();
}
public static void main(String[] args) {
System.out.println(check(1, 100, 0.04));
System.out.println(checkClosed(2, 0.04));
}
}