Skip to content

Instantly share code, notes, and snippets.

@jeyziel
Created October 22, 2017 22:36
Show Gist options
  • Save jeyziel/711e7d21df29501c7ee9d576fa49f795 to your computer and use it in GitHub Desktop.
Save jeyziel/711e7d21df29501c7ee9d576fa49f795 to your computer and use it in GitHub Desktop.
filtrar apenas os números que sejam resultado de uma raíz cúbica onde o radicando seja ímpar
const pow = ( y ) => ( x ) => Math.pow( x, y )
const cube = pow(3)
const NOT = ( x ) => !x
const isDivisibleBy = ( y ) => ( x ) => NOT( x % y )
const isEven = isDivisibleBy(2)
const isOdd = ( x ) => NOT( isEven( x ) )
const N = [1,2,3,4,5,6,7,8,9,10]
const radicandoIsOdd = ( x ) => isOdd( cube( x ) )
const filterRadicando = N.filter( radicandoIsOdd )
console.log( filterRadicando ) //[ 1, 3, 5, 7, 9 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment