Skip to main content
added 260 characters in body
Source Link
G B
  • 22.8k
  • 1
  • 20
  • 53

Ruby, 42 bytes

->c,n,x{n.times{x=c.reduce{|s,r|s*x+r}};x}

C is the list of coefficients in descending order

Trivial version, where f is a lambda function (26 bytes):

->f,n,x{n.times{x=f[x]};x}

# For example:
# g=->f,n,x{n.times{x=f[x]};x}
# p g[->x{0.02*x**4-0.01*x**2-0.05},100,0.1]

Try it online!

Ruby, 42 bytes

->c,n,x{n.times{x=c.reduce{|s,r|s*x+r}};x}

Try it online!

Ruby, 42 bytes

->c,n,x{n.times{x=c.reduce{|s,r|s*x+r}};x}

C is the list of coefficients in descending order

Trivial version, where f is a lambda function (26 bytes):

->f,n,x{n.times{x=f[x]};x}

# For example:
# g=->f,n,x{n.times{x=f[x]};x}
# p g[->x{0.02*x**4-0.01*x**2-0.05},100,0.1]

Try it online!

Source Link
G B
  • 22.8k
  • 1
  • 20
  • 53

Ruby, 42 bytes

->c,n,x{n.times{x=c.reduce{|s,r|s*x+r}};x}

Try it online!