Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda