diff --git a/_posts/2016-04-15-laziness-is-a-virtue.md b/_posts/2016-04-15-laziness-is-a-virtue.md index cfa82ca0c..d28c44f7b 100644 --- a/_posts/2016-04-15-laziness-is-a-virtue.md +++ b/_posts/2016-04-15-laziness-is-a-virtue.md @@ -219,18 +219,11 @@ Let's take a pass at writing the Sieve of Eratosthenes in lazy style. First off, [ja]: https://leanpub.com/javascriptallongesix {% highlight javascript %} -function * range (from = 0, to = null) { +function * range (from = 0, to = Number.MAX_VALUE) { let number = from; - if (to == null) { - while (true) { - yield number++ - } - } - else { - while (from <= to) { - yield number++; - } + while (number <= to) { + yield number++; } }