Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
stopping a higher order function generating numbers at certain number

I have a function that takes another function that generates consecuitive numbers

(numbers can be generated from any start point)

also the function takes a value which it should stop before

i can get it to work from zero up to the required limit but not if for expample it starts at 1

these are requirements:

returns a function on first invocation
✓ returns given value on first call
✓ Subsequent invocations emits consecutive integers (1 ms)
✓ exclusively emits undefined when surpassed limit (not inclusive) (1 ms)
✕ exclusively emits undefined when surpassed limit (not inclusive) when generator does not start at 0

hof.to = function (funcfrom, n) {
  counter = n;
  return function () {
    if (counter > 0) {
      counter--;
      return funcfrom();
    }
  };
};
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda