Last active
April 10, 2020 07:02
-
-
Save enshahar/d48901f3b8bb5ea30ded3c8777dd97f3 to your computer and use it in GitHub Desktop.
원소 100만개 짜리 시퀀스도 리스트로 못 바꾸는 안습한 코틀린 이라고 생각한 안습한 밥팅 나
This file contains hidden or 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
import java.lang.Runtime.getRuntime | |
fun main() { | |
println("max: ${getRuntime().maxMemory()}, total: ${getRuntime().totalMemory()}, free: ${getRuntime().freeMemory()}") | |
// 여기서 100_0000는 원소 갯수가 아니고, 시드값임. | |
// 두번째로 오는 람다에서 널을 반환하면 시퀀스가 끝남 | |
// 따라서 나라는 밥팅은 100_0000이 들어있는 무한 시퀀스를 만든 것임. | |
val seq1 = generateSequence(100_0000) { it } | |
val list1 = seq1.toList() | |
println(list1[1]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment