Upgrade to Pro — share decks privately, control downloads, hide ads and more …

3分でわかるSequence

scache
August 25, 2018

 3分でわかるSequence

KotlinのSequence処理の流れについて
@Kotlin Fest 2018

scache

August 25, 2018
Tweet

More Decks by scache

Other Decks in Programming

Transcript

  1. ࠷ऴతʹಘΒΕΔϦετ͸ಉ͡ ʢ෭࡞༻ͳ͠ͷ࣌) (1..100) .map { it * 10 } .filter

    { it < 825 } .take(2) (1..100).asSequence() .map { it * 10 } .filter { it < 825 } .take(2) .toList() [10, 20]
  2. List (1..100) .map { it * 10 } .filter {

    it < 825 } .take(2) [10, 20, … , 1000]
  3. List (1..100) .map { it * 10 } .filter {

    it < 825 } .take(2) [10, 20, … , 820]
  4. List (1..100) .map { it * 10 } .filter {

    it < 825 } .take(2) [10, 20]
  5. (1..100).asSequence() .map { it * 10 } .filter { it

    < 825 } .take(2) .toList() Sequence
  6. (1..100).asSequence() .map { it * 10 } .filter { it

    < 825 } .take(2) .toList() Sequence
  7. (1..100).asSequence() .map { it * 10 } .filter { it

    < 825 } .take(2) .toList() Sequence
  8. (1..100).asSequence() .map { it * 10 } .filter { it

    < 825 } .take(2) .toList() Sequence
  9. (1..100).asSequence() .map { it * 10 } .filter { it

    < 825 } .take(2) .toList() Sequence
  10. (1..100).asSequence() .map { it * 10 } .filter { it

    < 825 } .take(2) .toList() Sequence
  11. Sequence 1 2 3 … 100 map { it *

    10 } filter { it < 825 } take(2) toList()
  12. Sequence 1 2 3 … 100 map { it *

    10 } 10 filter { it < 825 } take(2) toList()
  13. Sequence 1 2 3 … 100 map { it *

    10 } 10 filter { it < 825 } ↓ take(2) toList()
  14. Sequence 1 2 3 … 100 map { it *

    10 } 10 filter { it < 825 } ↓ take(2) ↓ toList()
  15. Sequence 1 2 3 … 100 map { it *

    10 } 10 filter { it < 825 } ↓ take(2) ↓ toList() 10
  16. Sequence 1 2 3 … 100 map { it *

    10 } 10 20 filter { it < 825 } ↓ ↓ take(2) ↓ ↓ toList() 10 20
  17. Sequence 1 2 3 … 100 map { it *

    10 } 10 20 filter { it < 825 } ↓ ↓ take(2) ↓ ↓ toList() 10 20
  18. (1..100).asSequence() .map { it * 10 } .filter { it

    < 825 } .take(2) .toList() Sequence [10, 20]