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

Lazy List With Generator and Iterator

Joe Wang
August 19, 2018

Lazy List With Generator and Iterator

An Intro to lazy list implementation with generator and iterator.

Joe Wang

August 19, 2018
Tweet

More Decks by Joe Wang

Other Decks in Programming

Transcript

  1. LAZY LIST
    WITH
    GENERATOR AND ITERATOR
    Joe Wang

    View Slide

  2. Lazy List in Haskell
    Examples:

    View Slide

  3. Can we do the same thing in JavaScript?
    Is there any structure is lazy in JavaScript?

    View Slide

  4. Lazy In JavaScript
    Function call

    View Slide

  5. Lazy In JavaScript
    Generator

    View Slide

  6. The Structure of Lazy List
    LAZY LIST
    SEQUENCE ITERATOR
    https://github.com/dtao/lazy.js 5000+star

    View Slide

  7. Iterable Interfaces

    View Slide

  8. Iterable
    ITERABLE
    Array
    String
    Map
    Set
    for…of…
    …itor
    Array.from

    View Slide

  9. Infinite Fibonacci

    View Slide

  10. Generator

    View Slide

  11. Generator - repeat

    View Slide

  12. Generator - iterate

    View Slide

  13. Generator - cycle

    View Slide

  14. Generator - map/filter

    View Slide

  15. Generator - take

    View Slide

  16. Generator - take

    View Slide

  17. Usage

    View Slide

  18. Usage

    View Slide

  19. Usage

    View Slide

  20. View Slide

  21. let’s wrap it

    View Slide

  22. The End
    https://github.com/nodew/lazyList

    View Slide