Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

298
Views
¿Es posible obtener una función "inversa" de una función booleana en javascript?

Estaba buscando escribir una función de "todo o nada" sobre una matriz. Un enfoque es, por supuesto, aprovechar Array.prototype.every y hacer algo como

 function allOrNothing(arr, f, fInv) { return arr.every(f) || arr.every(fInv); }

donde f y fInv son funciones indicadoras, y fInv es una función "inversa" de f . Por ejemplo, si f = (x) => x != null , entonces fInv = (x) => x == null .

Esto me lleva a pensar: ¿es posible obtener la función fInv de f ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esta función, dada una función f como entrada, devuelve su inversa booleana:

let invert = (f) => (x) => !f(x)

p.ej

 let invert = (f) => (x) => !f(x) let eq_five = (x) => x == 5 let neq_five = invert(eq_five) console.log(eq_five(5)) // true console.log(neq_five(5)) // false

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!