kotlin filter map by key

data class Person(val id: Int, val name: String)

fun main() {
    val people = listOf(
        Person(1, "Alice"),
        Person(2, "Bob"),
        Person(3, "Charlie"),
        Person(4, "David")
    )

    val idsToFilter = setOf(2, 4)

    val filteredPeople = people
        .filter { it.id in idsToFilter }
        .map { it.id to it.name }

    println(filteredPeople)
}