Skip to content

Instantly share code, notes, and snippets.

@timbertson
Created April 26, 2010 12:27
Show Gist options
  • Save timbertson/379263 to your computer and use it in GitHub Desktop.
Save timbertson/379263 to your computer and use it in GitHub Desktop.
(function(){
var _a, _b, _c, _d, evens, num;
evens = (function() {
_a = []; _c = [1, 2, 3, 4, 5, 6];
for (_b = 0, _d = _c.length; _b < _d; _b++) {
num = _c[_b];
num % 2 === 0 ? _a.push((function() {
num *= -1;
num -= 2;
return num * -1;
})()) : null;
}
return _a;
})();
})();
(function(){
var _a, _b, _c, _d, evens, num;
evens = (function() {
_a = []; _c = [1, 2, 3, 4, 5, 6];
for (_b = 0, _d = _c.length; _b < _d; _b++) {
num = _c[_b];
num % 2 === 0 ? _a.push( num *= -1;
num -= 2;
return num * -1;) : null;
}
return _a;
})();
})();
// note the lack of enclosing function
evens: for num in [1, 2, 3, 4, 5, 6] when num % 2 is 0
num *= -1
num -= 2
num * -1
@timbertson
Copy link
Author

(note the missing function(){} wrapper around the expression being pushed into the accumulator array _a)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment