df
03/23/2021, 11:23 AMRob Elliot
03/23/2021, 11:26 AMmap1 + map2df
03/23/2021, 11:27 AMdf
03/23/2021, 11:27 AMRob Elliot
03/23/2021, 11:28 AMmaps.reduce { accumulator, next -> accumulator + next }df
03/23/2021, 11:28 AMdf
03/23/2021, 11:29 AMRob Elliot
03/23/2021, 11:31 AMdf
03/23/2021, 11:31 AMRob Elliot
03/23/2021, 11:32 AMmaps.reduceOrNull { accumulator, next -> accumulator + next } ?: emptyMap() would workdave08
03/23/2021, 12:06 PMbuildMap { maps.forEach { putAll(it) } } would avoid creating a new map for each iteration though...dave08
03/23/2021, 12:08 PMNir
03/23/2021, 12:10 PMNir
03/23/2021, 12:11 PMdf
03/23/2021, 1:09 PMdf
03/23/2021, 1:11 PMList<Map<String, List<String>> into Map<String, List<String>>. This time the values for the same keys should be combined. Came up with this
val familyToCodes = mutableMapOf<String, MutableList<String>>()
allAssets.forEach { assets ->
assets.forEach { (attributeFamily, assetCodes) ->
familyToCodes.getOrPut(attributeFamily) { mutableListOf() }
.addAll(assetCodes)
}
}
failed to convert it to fold or buildMaps 😉dave08
03/23/2021, 1:13 PMval immutableFamilyToCodesMap = buildMap {
allAssets.forEach { assets ->
assets.forEach { (attributeFamily, assetCodes) ->
getOrPut(attributeFamily) { mutableListOf() }
.addAll(assetCodes)
}
}
}dave08
03/23/2021, 1:14 PMMap that's not mutable at the end...df
03/23/2021, 1:16 PMNir
03/23/2021, 1:35 PMNir
03/23/2021, 1:35 PMNir
03/23/2021, 1:35 PMNir
03/23/2021, 1:36 PMgroupByNir
03/23/2021, 1:37 PMgroupingBy with some aggregate etc follow upNir
03/23/2021, 1:39 PM