This file contains hidden or 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
{ | |
"name": "windows-aliases", | |
"version": "1.0.0", | |
"description": "", | |
"main": "", | |
"dependencies": {}, | |
"devDependencies": {}, | |
"scripts": { | |
"bash": "bash.exe -cur_console:p", | |
"test": "echo \"Error: no test specified\" && exit 1" |
This file contains hidden or 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
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md | |
new file mode 100644 | |
index 0000000..42f7332 | |
--- /dev/null | |
+++ b/CODE_OF_CONDUCT.md | |
@@ -0,0 +1,46 @@ | |
+# Contributor Covenant Code of Conduct | |
+ | |
+## Our Pledge | |
+ |
This file contains hidden or 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 fib(number) { | |
if (number < 2) return number; | |
return (fib(number - 1) + fib(number - 2)); | |
} |
This file contains hidden or 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
def fib(n) | |
return n if n < 2 | |
# ruby has implicit returns | |
# so no need to say return on the last line here | |
fib(n - 1) + fib(n - 2) | |
end | |
def memo_fib(n, cache = {}) | |
return n if n < 2 |
This file contains hidden or 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
const fib = (num, cache = {}) => { | |
if (num < 2) return num; | |
// if the cached result exists, return the cached result | |
if (cache[num]) return cache[num]; | |
// otherwise, create a new entry in the cache with the new result | |
return Object.assign( | |
cache, | |
{ [num]: (fib(num - 1, cache) + fib(num - 2, cache)) }, | |
)[num]; | |
// ^^ and return the result so recursion can continue |
This file contains hidden or 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
cache[n] = fib(num - 1, cache) + fib(num - 2, cache); | |
return cache[n]; |
This file contains hidden or 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
return Object.assign( | |
{}, // << this is the important part - LOOK HERE! | |
cache, | |
{ [num]: (fib(num - 1, cache) + fib(num - 2, cache)) }, | |
)[num]; |
This file contains hidden or 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 fib(n, cache) { | |
cache = cache || {}; | |
if (n < 2) { | |
return n; | |
} else { | |
if (cache[n]) { | |
return cache[n] | |
} else { | |
cache[n] = fib(n - 1, cache) + fib(n - 2, cache); |
This file contains hidden or 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
const fib = (num, cache = {}) => (num < 2) | |
? num | |
: cache[num] || Object | |
.assign(cache, { [num]: (fib(num - 1, cache) + fib(num - 2, cache)) }) | |
[num]; |
This file contains hidden or 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 names = [ | |
["John", "Brown"], | |
["Lisa", "May"], | |
["Henry", "Ford"], | |
]; | |
function displayLastName(inputName) { | |
// first we are going to map through the names array | |
// return null for anything that doesn't match | |
return names |