Skip to content

Instantly share code, notes, and snippets.

@toantran-ea
Created July 9, 2020 22:27
Show Gist options
  • Save toantran-ea/7e84b338a11de47c952617beca28deb3 to your computer and use it in GitHub Desktop.
Save toantran-ea/7e84b338a11de47c952617beca28deb3 to your computer and use it in GitHub Desktop.
sequence 1
fun main(args: Array<String>) {
val seq = sequenceOf("a", "ba", "cda", "def")
val filter1 = seq.filter {
it.length > 1
}
println(filter1) // kotlin.sequences.FilteringSequence@28a418fc
val filter2 = filter1.filter {
it.length > 2
}
println(filter2) // kotlin.sequences.FilteringSequence@5305068a
val end = filter2.toList(); // terminal
println(end) // [cda, def]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment