Complete the code to filter a list of numbers to keep only even numbers.
val evens = numbers.[1] { it % 2 == 0 }
The filter function selects elements matching the condition.
Complete the code to transform a list of strings to their lengths.
val lengths = words.[1] { it.length }The map function transforms each element to another value.
Fix the error in the code to sum all numbers in the list.
val total = numbers.[1] { acc, num -> acc + num }The reduce function combines elements using the lambda to produce a single result.
Fill both blanks to create a map of words to their uppercase forms, filtering only words longer than 3 letters.
val result = words.[1] { it.length > 3 }.[2] { it to it.uppercase() }
First, filter keeps words longer than 3 letters, then map transforms each word to a pair of the word and its uppercase.
Fill all three blanks to create a map of uppercase words to their lengths, filtering words starting with 'a'.
val result = words.[1] { it.startsWith("a") }.[2] { it.uppercase() }.[3] { it to it.length }
First, filter selects words starting with 'a', then map converts them to uppercase, and finally associate creates a map from uppercase words to their lengths.