Last active
February 24, 2017 19:48
-
-
Save dmmfll/ebe8a27bb7590194994685d71f861301 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
gist_url | |
auto_gistup | |
.ipynb_checkpoints/ | |
Untitled* |
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
var i = 11; | |
while ( i-- ){ // exists because 0 is false in JS | |
console.log(i) | |
} | |
var lowercase_letters = function (cFrom, cTo) { | |
function cRange(cFrom, cTo) { | |
var iStart = cFrom.charCodeAt(0); | |
return Array.apply( | |
null, Array(cTo.charCodeAt(0) - iStart + 1) | |
).map(function (_, i) { | |
return String.fromCharCode(iStart + i); | |
}); | |
} | |
return cRange(cFrom, cTo); | |
}; | |
var letters = lowercase_letters('a', 'z'), | |
i = letters.length, | |
letter; | |
letters.reverse(); | |
while ( i-- ){ | |
letter = letters[i]; | |
console.log(letter); | |
} | |
// recursive countdown | |
var countdown = function countdown(x){ | |
if (x === 0){ | |
return; | |
} | |
x -= 1; | |
console.log(x); | |
return countdown(x); | |
} | |
countdown(10); |
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
integers = [3, 5] | |
number_range = (0..10) | |
sum = integers.map {|n| number_range.step(n).to_a} | |
.flatten | |
.inject(:+) | |
puts sum | |
integers = [3, 5] | |
number_range = (0..10) | |
sum = integers.map {|n| number_range.step(n).to_a} | |
puts sum | |
integers = [3, 5] | |
number_range = (0..10) | |
sum = integers.map {|n| number_range.step(n).to_a} | |
.flatten | |
puts sum | |
integers = [3, 5] | |
number_range = (0..10) | |
sum = integers.map {|n| number_range.step(n).to_a} | |
.flatten | |
.inject(:+) | |
puts sum |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment