Last active
September 8, 2021 18:55
-
-
Save lukkaslt/a3a1e29ff2d4ef7549946e1a8ada8342 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
const sucessor = (n) => { | |
return n + 1; | |
}; | |
const somarNaturais = (x, y, acc=y, coun=x) => { | |
return x <= 0 && y || (!!coun) && somarNaturais(x, y, sucessor(acc), coun-1) || acc; | |
}; | |
// Range melhorado | |
function reverse([x, ...xs]) { | |
return x !== void 0 && [...reverse(xs), x] || [] | |
} | |
intervaloAux = function (x, y) { | |
return ( x <= y ) && [ x, ...intervaloAux( x+1, y ) ] | |
|| x === void 0 && [ x, ...intervaloAux( x-1, y ) ] | |
|| []; | |
} | |
var intervalo = function( x, y ) { | |
return (y < x) && reverse(intervaloAux(y, x)) || intervaloAux(x, y) | |
}; | |
const compararListas = ( xs, ys, aux=0) => { | |
return aux <= xs.length | |
? xs[aux] === ys[aux] && compararListas(xs, ys, aux+1) | |
: true; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment