I'm new to Kotlin and would like to combine all elements of a list.
I tried zipWithNext, but it combines an element only with the next one.
val letters = ('a'..'f').toList()
val pairs = letters.zipWithNext()
println(letters) // [a, b, c, d, e, f]
println(pairs) // [(a, b), (b, c), (c, d), (d, e), (e, f)]
I'd like something like this:
From this [a, b, c, d] to this [(a, b), (a, c), (a, d), (b, a), (b, c), (b, d), (c, a), (c, b), (c, d), (d, a), (d, b), (d, c)]
It can be done in imperative way, but I was wonder how to do it in a functional way.