Map

fun checkDefaultMapOperator() {
    val numbers = setOf(1, 2, 3)
    println(numbers.map { it * 3 })
    println(numbers.mapIndexed { idx, value -> value * idx })

    val numbersNullCheck = setOf(1, 2, 3)
    println(numbersNullCheck.mapNotNull { if ( it == 2) null else it * 3 })
    println(numbersNullCheck.mapIndexedNotNull { idx, value -> if (idx == 0) null else value * idx })
}
fun makeMapCollectionUsingMapOperator() {
    val numbersMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3, "key11" to 11)
    println(numbersMap.mapKeys { it.key.toUpperCase() })
    println(numbersMap.mapValues { it.value + it.key.length })
}

Zip

fun checkDefaultZipOperator() {
    val colors = listOf("red", "brown", "grey")
    val animals = listOf("fox", "bear", "wolf")
    println(colors zip animals)

    val twoAnimals = listOf("fox", "bear")
    println(colors.zip(twoAnimals))
}
fun checkZipUsingTransformFunction() {
    val colors = listOf("red", "brown", "grey")
    val animals = listOf("fox", "bear", "wolf")

    println(colors.zip(animals) { color, animal -> "The ${animal.capitalize()} is $color"})
}
fun checkUnzipFunction() {
    val numberPairs = listOf("one" to 1, "two" to 2, "three" to 3, "four" to 4)
    println(numberPairs.unzip())
}

Associate

fun checkAssociateWithOperator() {
    val numbers = listOf("one", "two", "three", "four")
    println(numbers.associateWith { it.length })
}