fun funcSum1(funcs: List<() -> Int>): Int =
funcs.map { it() }.sum()
Function Call | Return Value | |||
---|---|---|---|---|
funcSum1(listOf({ 5 }, { 3 })) | → | |||
funcSum1(listOf({ 8 }, { 6 }, { 11 })) | → | |||
funcSum1(listOf({ 1 }, { 2 }, { 3 }, { 4 })) | → | |||
funcSum1(listOf({ 9 }, { 9 })) | → |
Experiment with this code on Gitpod.io or as a Kotlin Playground