A poor man's for-comprehension (as in Scala) or do-notation (as in Haskell) for stream composition in Java.
For Kotlin users, Λrrow is a better alternative.
repositories {
mavenCentral()
maven("https://jitpack.io")
}
dependencies {
implementation("io.github.portfoligno", "stateful-cartesian-streams", VERSION)
}
List<Integer> combinations = StatefulCartesian
.stream(c -> {
int i = c.pull(List.of(-1, 0, 1));
int j = c.pull(List.of(700, 800, 900));
int k = c.pull(List.of(1, 2, 3));
return i * (j + k);
})
.collect(toList());
System.out.println(combinations);
// [-701, -702, -703, -801, -802, -803, -901, -902, -903, 0, 0, 0, 0, 0, 0, 0, 0, 0, 701, 702, 703, 801, 802, 803, 901, 902, 903]