Using `ListK.applicative()` and `tupled(listA.k(),...
# arrow
r
Using
ListK.applicative()
and
tupled(listA.k(), listB.k()
, I can generate all `Tuple2`'s with the elements in both lists. If I give more arguments to
tupled
, then I get a
Tuple3
, etc. Is there a way to give more arguments to a method like
tupled
but still only get a
Tuple2
out? I want to get all the pairs of elements between n lists.
r
The issue here is that you want to obtain a Tuple2<A, B> from the result of parameterizing over n lists like List<A>, List<B>, List<C>,…
so once you have C? how do you represent the fact that Tuple2 is parametric to two type argument whereas ListN can have arbitrary arity and therefore produce more than than A and B
What would be the function signature regardless of implementation that you expect?
Based on your comment I´m reading…
Copy code
fun <A, B, C> unknown(la: List<A>, lb: List<B>, lc: List<C>): List<Tuple2<?, ?> = TODO()
r
I agree that general case isn't reasonable, but I was thinking:
Copy code
fun <A> tupled(a: List<A>, b: List<A>, c: List<A>): List<Tuple2<A, A>> = TODO()
All the pairs of
a
and
b
, all the pairs of
b
and
c
, and all the pairs of
a
and
c
.