I am investigating some of the components in Java and wondering what is the best practice to convert the following Java code snippet to Swift.
public void doTest(ArrayList<Double> items) {
// I know that I should check the count of items. Let's say the count is 10.
double max = IntStream.range(1, 5)
.mapToDouble(i -> items.get(i) - items.get(i - 1))
.max().getAsDouble();
}
AlI I know is there is no equivalent parallel aggregate operations in Swift to replicate the IntStream. Do I need to write some nested loops or any better solution? Thank you.