Can You share any good solution for creating immutable collection in Scala based on full iteration of items in several arrays/another collections?
E.g. in Java you can use:
List<String> signals = ...;
List<SignalState> states = ...;
List<SignalAndState> result = new ArrayList<~>(signals.size() * states.size());
for (String signal: signals) {
for (SignalState state: states) {
// some if() condition or process() function can be here
result.add(new SignalAndState(signal, state))
}
}
What are the best practices of building smth like this using Scala? The same approach (using for() in for()) is bad idea, I think, and is not compatible with object-functional nature of Scala language at all.