How to resolve the algorithm Averages/Root mean square step by step in the Nemerle programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Averages/Root mean square step by step in the Nemerle programming language
Table of Contents
Problem Statement
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean. The RMS is calculated as the mean of the squares of the numbers, square-rooted:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Averages/Root mean square step by step in the Nemerle programming language
Source code in the nemerle programming language
using System;
using System.Console;
using System.Math;
module RMS
{
RMS(x : list[int]) : double
{
def sum = x.Map(fun (x) {x*x}).FoldLeft(0, _+_);
Sqrt((sum :> double) / x.Length)
}
Main() : void
{
WriteLine("RMS of [1 .. 10]: {0:g6}", RMS($[1 .. 10]));
}
}
You may also check:How to resolve the algorithm Word wrap step by step in the V (Vlang) programming language
You may also check:How to resolve the algorithm Sorting algorithms/Sleep sort step by step in the Python programming language
You may also check:How to resolve the algorithm Animation step by step in the Yabasic programming language
You may also check:How to resolve the algorithm Hailstone sequence step by step in the Euphoria programming language
You may also check:How to resolve the algorithm Remove duplicate elements step by step in the SETL4 programming language