// Single-Expression, Multi-Use Functions // is the string representation of the argument non-empty? fun hasLength(s: String) = s.length > 0 println(listOf("a", "bb", "ccc", "").map(::hasLength)) println(listOf("a", "bb", "ccc", "").filter(::hasLength)) // single-use, anonymous function literals // (aka lambda functions) repeat(5, { println("👋") }) val nums = listOf(1, 3, 5) println(nums) // increment the numbers val incremented = nums.map { it + 1 } println("incremented: $incremented") // sum the numbers val summed = nums.fold(0, { sum, n -> sum + n }) println("summed: $summed") // count the enumbers (just an example, should just .size) val counted = nums.fold(0) { count, _ -> count + 1 } println("counted: $counted")