nickk
08/18/2017, 1:51 PMkingsley
08/18/2017, 1:55 PMzipWithNext that does exactly that was just introduced in 1.2M2kingsley
08/18/2017, 1:55 PMhho
08/18/2017, 2:08 PMval lats = latLongs.filterIndexed { index, _ -> index % 2 == 0 }
val longs = latLongs.filterIndexed { index, _ -> index % 2 != 0 }
val coords = lats.zip(longs)arekolek
08/18/2017, 3:12 PM(x.indices step 2).map { LatLng(x[it], x[it + 1]) }arekolek
08/18/2017, 3:28 PMzipWithNext returns a list of all adjacent pairsarekolek
08/18/2017, 3:29 PM(1..5).zipWithNext { a, b -> println("$a, $b") } prints:
1, 2
2, 3
3, 4
4, 5arekolek
08/18/2017, 3:33 PMx.chunked(2) { LatLng(it[0], it[1]) } would do it though