Skip to content

Instantly share code, notes, and snippets.

@lukkaslt
Last active September 8, 2021 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukkaslt/a3a1e29ff2d4ef7549946e1a8ada8342 to your computer and use it in GitHub Desktop.
Save lukkaslt/a3a1e29ff2d4ef7549946e1a8ada8342 to your computer and use it in GitHub Desktop.
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