Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created May 4, 2021 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CheolhoJeon/841167c2133c6e6c1a570baf787e1e0d to your computer and use it in GitHub Desktop.
Save CheolhoJeon/841167c2133c6e6c1a570baf787e1e0d to your computer and use it in GitHub Desktop.
package chap4.Sequences
import atomictest.eq
fun main() {
val list = listOf(1, 2, 3, 4)
list.filter { it % 2 == 0 }
.map { it * it }
.any { it < 10 } eq true
// Equivalent to:
val mid1 = list.filter { it % 2 == 0 }
mid1 eq listOf(2, 4)
val mid2 = mid1.map { it * it }
mid2 eq listOf(4, 16)
mid2.any { it < 10 } eq true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment