Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handle infinite lists in CoffeeScript

In Haskell I can do this to handle an infinite list.

takeWhile (<1000) [1 ..]

Is there a way to this in CoffeeScript?

like image 569
marknery Avatar asked Jan 24 '12 18:01

marknery


1 Answers

StreamJS enables the creation of 'infinite' lists in javascript.

Using it's (rough) coffeescript port:

# Stream.range() creates a list from 1...Infinity
numbers = Stream.range().until (x) -> x > 1000
like image 118
Ricardo Tomasi Avatar answered Oct 06 '22 02:10

Ricardo Tomasi