mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00

* Documentation of `for...from` for iterating over generator functions
* Add note that the CoffeeScript compiler does not, in fact, generate JavaScript that runs in every JavaScript runtime 😢
13 lines
279 B
CoffeeScript
13 lines
279 B
CoffeeScript
fibonacci = ->
|
|
[previous, current] = [1, 1]
|
|
loop
|
|
[previous, current] = [current, previous + current]
|
|
yield current
|
|
return
|
|
|
|
getFibonacciNumbers = (length) ->
|
|
results = [1]
|
|
for n from fibonacci()
|
|
results.push n
|
|
break if results.length is length
|
|
results
|