mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 17:27:59 -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 😢
14 lines
279 B
CoffeeScript
14 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
|