Created
September 16, 2019 11:19
-
-
Save MarcinMoskala/d7d5caddf3b7d2007037995a6d95508a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public inline fun <T> List( | |
size: Int, | |
init: (index: Int) -> T | |
): List<T> = MutableList(size, init) | |
public inline fun <T> MutableList( | |
size: Int, | |
init: (index: Int) -> T | |
): MutableList<T> { | |
val list = ArrayList<T>(size) | |
repeat(size) { index -> list.add(init(index)) } | |
return list | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment