Skip to content

Instantly share code, notes, and snippets.

@stevegraham
Created October 10, 2011 21:39
Show Gist options
  • Select an option

  • Save stevegraham/1276633 to your computer and use it in GitHub Desktop.

Select an option

Save stevegraham/1276633 to your computer and use it in GitHub Desktop.
list = [1..10]
squares = list.map (num) -> num * num
squares = (num * num for num in list)
// Compiles to...
var list, num, squares;
list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
squares = list.map(function(num) {
return num * num;
});
squares = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = list.length; _i < _len; _i++) {
num = list[_i];
_results.push(num * num);
}
return _results;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment