Hacker News new | past | comments | ask | show | jobs | submit login

Close, but I checked it and the value of `i` won't bind to the function. You also have to use `...` (exclusive range) instead of `..` to prevent an off-by-one error.

Here's one way:

    foo = (n) -> ((a) -> a).bind(null, i) for i in [0...n]
Here's a more esoteric/bad style (but cute) way:

    foo = (n) -> (-> +@).bind i for i in [0...n]



I've been preferring explicit `map()`s in my CoffeeScript for exactly that reason.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: