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

155
Vistas
Infinite streams in JavaScript (how to multiply two series which are represented as a stream of coefficients using streams)

I am trying to create a function which takes in two streams of coefficients and will multiply them. For example, the series 1+2x+3x^2 is represented as (1,2,3). If I had the two series 1+2x+3x^2 and 2+6x+9x^2, the output of this function will be 2+10x+27x^2+36x^3+27x^4 or (2,10,27,36,27,...).

My addSeries function goes like this:

function addSeries(s,t){
  if(s.toString() === "sempty" && t.toString() === "sempty"){ 
    return sempty;
  }
  else if(s.toString() === "sempty"){ 
    return snode(t.head(), memo0(() => addSeries(t.tail(),s)));
  }
  else if(t.toString() === "sempty"){
    return snode(s.head(), memo0(() => addSeries(s.tail(),t)));
  }
  return snode(s.head() + t.head(), memo0(() => addSeries(s.tail(),t.tail())));
}

How can I use this same principle to multiply two streams?

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