paint-brush
How I Used Proxy to Implement Lazy Infinite Lists in JavaScriptby@sjsyrek
1,909 reads
1,909 reads

How I Used Proxy to Implement Lazy Infinite Lists in JavaScript

by Steven Syrek20mDecember 4th, 2016
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

In this article, I will present a JavaScript ES6 implementation of a lazily-evaluated <a href="https://en.wikipedia.org/wiki/Linked_list" target="_blank">linked list</a> data structure. The recursively-defined linked list is an important collection type in many functional <a href="https://hackernoon.com/tagged/programming" target="_blank">programming</a> languages. In the <a href="https://haskell-lang.org/" target="_blank">Haskell language</a>, which inspired this project, the <a href="https://en.wikibooks.org/wiki/Haskell/Lists_and_tuples" target="_blank">list datatype</a> fills the role that arrays occupy in <a href="https://hackernoon.com/tagged/javascript" target="_blank">JavaScript</a>. Since this list type is defined using <a href="https://en.wikipedia.org/wiki/Recursion_%28computer_science%29" target="_blank">recursion</a>, it is possible to generate and evaluate list elements on demand, rather than at the time of the list’s creation (that’s the “lazy” part), thereby making infinite lists not only feasible but relatively straightforward.

People Mentioned

Mention Thumbnail
Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How I Used Proxy to Implement Lazy Infinite Lists in JavaScript
Steven Syrek HackerNoon profile picture
Steven Syrek

Steven Syrek

@sjsyrek

L O A D I N G
. . . comments & more!

About Author

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite