Sebastian Lehrbaum
04/20/2023, 5:40 PMmapOf("x" to map.keys, "y" to map.values)
however keys and values on maps are sets, they are not ordered so how would I know that the value pairs would stay in the correct order?Adam S
04/20/2023, 5:42 PMSebastian Lehrbaum
04/20/2023, 5:46 PMfun Map<Int, Int>.toPlotData(xTitle: String, yTitle: String): Map<String, List<Int>> {
val plotPoints = this.entries
.sortedBy { it.key }
.fold(Pair(mutableListOf<Int>(), mutableListOf<Int>())) { acc, (k, v) ->
acc.first += k
acc.second += v
acc
}
return mapOf(
xTitle to plotPoints.first,
yTitle to plotPoints.second
)
}
Pavel Gorgulov
04/20/2023, 5:50 PMSebastian Lehrbaum
04/20/2023, 5:54 PMPavel Gorgulov
04/20/2023, 5:56 PM%useLatestDescriptors
%use kandy
Sebastian Lehrbaum
04/20/2023, 6:01 PMPavel Gorgulov
04/20/2023, 6:03 PMSebastian Lehrbaum
04/20/2023, 6:07 PMmap.keys
and map.values
are Sets and since by default a set is backed by a hashmap, if that also uses a LinkedHashMap that means it should most likely be correctly ordered. Feels a bit weird to rely on the inner working like this, but I guess it will just work.Pavel Gorgulov
04/20/2023, 6:22 PMpip install kotlin-jupyter-kernel==0.11.0.348
Sebastian Lehrbaum
04/20/2023, 6:23 PMPavel Gorgulov
04/20/2023, 6:23 PMSebastian Lehrbaum
04/20/2023, 6:25 PMIgor Alshannikov
04/20/2023, 6:37 PMsrcMap.map { (k, v) -> k to v }.unzip()
Ilya Muradyan
04/20/2023, 6:58 PMHampus Londögård
04/21/2023, 5:35 AMkandy
to exist to have a multi-engine backend? Thinking it looks similar to lets-plot
right?Ilya Muradyan
04/21/2023, 9:19 AMHampus Londögård
04/21/2023, 9:20 AMSebastian Lehrbaum
04/21/2023, 11:31 AM._map_ *{ it*._toPair_() *}*._unzip_()