``` val (even, odd) = listOf(1.2, 2.0, 4.1, 6.0) ...
# announcements
e
Copy code
val (even, odd) = listOf(1.2, 2.0, 4.1, 6.0)
    .partition { it.isEven() }
q
Double havent this method in this case
isEven()
r
fun Double.isEven() = this.toInt() % 2 == 0
if you don't care about the decimal part
Copy code
>>> val x = listOf(1.2, 2.0, 4.1, 6.0).partition { it.isEven() }
>>> x
([2.0, 4.1, 6.0], [1.2])
q
dont need 2 separated list, i need list of Pairs where Pair.first is value with even index and second with odd, its not depend of double values
b
Copy code
listOf(1.2, 2.0, 4.1, 6.0)
                    .mapIndexed { i, t -> t to (i % 2 ==0) }
                    .partition { it.second }
                    .let {
                        it.first.zip(it.second) {a, b -> a.first to b.first}
                    }
r
Copy code
>>> listOf(1, 2, 4, 6).groupBy { it % 2 == 0 }.entries.toList()
[false=[1], true=[2, 4, 6]]
b
Thats not what he was looking for, he was asking for a "pairs()" implementation. I think there was a language misunderstanding 😄
👍 1
q
i have a list of Doubles - its a points from polygon object of javaFx, where values with even index is x and values with odd index is y, it is not divided to x and y, just list. Just want to separate it, that is all. But now i have another solution. Thanks to all