Created
April 26, 2010 12:27
-
-
Save timbertson/379263 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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; | |
})(); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
evens: for num in [1, 2, 3, 4, 5, 6] when num % 2 is 0 | |
num *= -1 | |
num -= 2 | |
num * -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(note the missing function(){} wrapper around the expression being pushed into the accumulator array _a)