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

161
Views
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
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!