Skip to content

Instantly share code, notes, and snippets.

@Nublo
Created October 7, 2018 14:52
Show Gist options
  • Save Nublo/8b9a7241d1dceb90835917e8c32525f6 to your computer and use it in GitHub Desktop.
Save Nublo/8b9a7241d1dceb90835917e8c32525f6 to your computer and use it in GitHub Desktop.
fun <T, R> List<T>.map(f: (T) -> R): List<R> = when (this.size) {
0 -> listOf()
else -> f(head) + tail.map(f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment