Cartesian products

In Groovy, given a sequence of function references (algorithms), and a sequence of pairs of integers (data), I can create the Cartesian product of these:

algorithms.collectMany{algorithm -> data.collect{datum -> [algorithm, datum[0], datum[1]]}}

it may be just the stress of having to get stuff together for a presentation on Saturday, but I cannot think of a good way of doing the same thing in Kotlin. Anyone any thoughts to help me achieve success?

I don't know groovy very well, but do you mean something like this?

algorithms.flatMap { algorithm -> data.map { datum -> algorithm(datum[0], datum[1]) } }

Yes the stress was a factor :-( flatMap was the thing I missed. However:

In the end I need an Object. I can currently get a [Ljava.util.List; but that is not good enough.

array(algorithms.flatMap({algorithm -> data.map({datum -> array(algorithm, *datum)})}))

Just curious: why do you need Object[][]?

It is a requirement of TestNG that DataProviders deliver Object[][]. Cédric has mentioned that he has no choice, it has to be this way.