How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the ATS programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the ATS programming language

Table of Contents

Problem Statement

A fast scheme for evaluating a polynomial such as: when is to arrange the computation as follows: And compute the result from the innermost brackets outwards as in this pseudocode: Task Description Cf. Formal power series

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the ATS programming language

Source code in the ats programming language

#include
"share/atspre_staload.hats"

fun
horner
(
  x: int, cs: List int
) : int = let
//
implement
list_foldright$fopr (a, b) = a + b * x
//
in
  list_foldright (cs, 0)
end // end of [horner]

implement
main0 () = let
  val x = 3
  val cs = $list{int}(~19, 7, ~4, 6)
  val res = horner (x, cs)
in
  println! (res)
end // end of [main0]

  

You may also check:How to resolve the algorithm 99 bottles of beer step by step in the Icon and Unicon programming language
You may also check:How to resolve the algorithm Mandelbrot set step by step in the Elixir programming language
You may also check:How to resolve the algorithm File size step by step in the Rust programming language
You may also check:How to resolve the algorithm Sorting algorithms/Shell sort step by step in the Liberty BASIC programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the SimpleCode programming language