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
export CLICOLOR=1 | |
#export PS1='\e[32;42m[\@]\$\em[' | |
export PS1='\[\e[30;93m[\@]\e[m\e[30;33m\w\e[m\e[30;93m \$\e[m\]' | |
export LSCOLORS="GxFxCxDxBxegedabagaced" |
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
//see if sequence of nums is in increasing order, but seq is allowed to decrease once. | |
//some shared stuff first: | |
var arr = [0,1,2,3,5,4,5,7]; | |
//currently these two functions are only used in v1 (v2-3 prints value of entire function) | |
const s = () => console.log("success"); | |
const f = () => console.log("failure"); | |
//v1 imperative style | |
function exeImperative(){ | |
let dec = 0; |
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
//version that only works for arrays of nums in JS | |
var array = [0,1,2,3,4,5,6,7,8,9] | |
var r, i = array.length | |
console.log(array) | |
while (i --> 1) { | |
r = Math.floor(Math.random()*i); | |
if(array[r] !== array[i]){ | |
array[r] = array[r] ^ array[i]; | |
array[i] = array[r] ^ array[i]; | |
array[r] = array[r] ^ array[i]; |
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
// Heron's method | |
function sqrt(n){ | |
var close_enuf = 0.001 | |
function iterate(guess){ | |
console.log(guess); | |
var next = (guess + n/guess)/2; | |
return (Math.abs(guess-next) < close_enuf) ? next : iterate(next); | |
} | |
iterate(Math.random()*n); | |
} |