task_url
stringlengths
30
116
task_name
stringlengths
2
86
task_description
stringlengths
0
14.4k
language_url
stringlengths
2
53
language_name
stringlengths
1
52
code
stringlengths
0
61.9k
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Common_Lisp
Common Lisp
(loop for x from 1 to 10 for xx = (* x x) for n from 1 summing xx into xx-sum finally (return (sqrt (/ xx-sum n))))
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Raku
Raku
my $e64 = ' VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2 9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g= ';   my @base64map = flat 'A' .. 'Z', 'a' .. 'z', ^10, '+', '/'; my %base64 is default(0) = @base64map.pairs.invert;   sub base64-decode-slow ($enc) { my $buf = Buf.new; for $enc...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Crystal
Crystal
def rms(seq) Math.sqrt(seq.sum { |x| x*x } / seq.size) end   puts rms (1..10).to_a
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#D
D
import std.stdio, std.math, std.algorithm, std.range;   real rms(R)(R d) pure { return sqrt(d.reduce!((a, b) => a + b * b) / real(d.length)); }   void main() { writefln("%.19f", iota(1, 11).rms); }
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Red
Red
Red [Source: https://github.com/vazub/rosetta-red]   print to-string debase "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"  
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Ring
Ring
  #======================================# # Sample: Base64 decode data # Author: Gal Zsolt, Mansour Ayouni #======================================#   load "guilib.ring"   oQByteArray = new QByteArray() oQByteArray.append("Rosetta Code Base64 decode data task") oba = oQByteArray.toBase64().data() see oba + nl   oQBy...
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Ruby
Ruby
require 'base64'   raku_example =' VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2 9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g= ' puts Base64.decode64 raku_example
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Delphi.2FPascal
Delphi/Pascal
program AveragesMeanSquare;   {$APPTYPE CONSOLE}   uses Types;   function MeanSquare(aArray: TDoubleDynArray): Double; var lValue: Double; begin Result := 0;   for lValue in aArray do Result := Result + (lValue * lValue); if Result > 0 then Result := Sqrt(Result / Length(aArray)); end;   begin Writeln...
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Rust
Rust
use std::str;   const INPUT: &str = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"; const UPPERCASE_OFFSET: i8 = -65; const LOWERCASE_OFFSET: i8 = 26 - 97; const NUM_OFFSET: i8 = 52 - 48;   fn main() { println!("Input: {}", INPUT);   let re...
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Scala
Scala
import java.util.Base64   object Base64Decode extends App {   def text2BinaryDecoding(encoded: String): String = { val decoded = Base64.getDecoder.decode(encoded) new String(decoded, "UTF-8") }   def data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgIC...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Action.21
Action!
INCLUDE "H6:REALMATH.ACT"   BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6 REAL r0,r4,r15,r16,r20,r22,r23,r24,r26,r28,r44,r85,r160   PROC Init() ValR("0",r0) ValR("0.04",r4) ValR("0.15",r16) ValR("0.16",r16) ValR("0.2",r20) ValR("0.22",r22) ValR("0.23",r23) ValR("0.24",r24) ValR("0.26",r26) ValR("0.28",r28...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#E
E
def makeMean(base, include, finish) { return def mean(numbers) { var count := 0 var acc := base for x in numbers { acc := include(acc, x) count += 1 } return finish(acc, count) } }   def RMS := makeMean(0, fn b,x { b+x**2 }, fn acc,n { (acc/n).sqrt...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#EchoLisp
EchoLisp
  (define (rms xs) (sqrt (// (for/sum ((x xs)) (* x x)) (length xs))))   (rms (range 1 11)) → 6.2048368229954285  
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Seed7
Seed7
$ include "seed7_05.s7i"; include "gethttp.s7i"; include "encoding.s7i";   const proc: main is func local var string: original is ""; var string: encoded is ""; begin original := getHttp("rosettacode.org/favicon.ico"); encoded := toBase64(original); writeln("Is the Rosetta Code icon the same...
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#SenseTalk
SenseTalk
    put base64Decode ("VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuIC0tUGF1bCBSLkVocmxpY2g=")    
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Ada
Ada
with Ada.Numerics.Discrete_Random;   with SDL.Video.Windows.Makers; with SDL.Video.Renderers.Makers; with SDL.Events.Events;   procedure Barnsley_Fern is   Iterations : constant := 1_000_000; Width  : constant := 500; Height  : constant := 750; Scale  : constant := 70.0;   type Percentage is r...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Elena
Elena
import extensions; import system'routines; import system'math;   extension op { get RootMeanSquare() = (self.selectBy:(x => x * x).summarize(Real.new()) / self.Length).sqrt(); }   public program() { console.printLine(new Range(1, 10).RootMeanSquare) }
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Sidef
Sidef
var data = <<'EOT' VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2 9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g= EOT   say data.decode_base64
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Smalltalk
Smalltalk
data := ' VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2 9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g= '.   data base64Decoded asString printCR.
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#ALGOL_68
ALGOL 68
  BEGIN INT iterations = 300000; LONG REAL scale x = 40, scale y = 40; [0:400,-200:200]CHAR canvas;   LONG REAL x := 0, y := 0;   FOR i FROM 1 LWB canvas TO 1 UPB canvas DO FOR j FROM 2 LWB canvas TO 2 UPB canvas DO canvas[i,j] := "0" OD OD;   canvas[0, 0] := "1"; TO iterations DO REAL cho...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Elixir
Elixir
  defmodule RC do def root_mean_square(enum) do enum |> square |> mean |> :math.sqrt end   defp mean(enum), do: Enum.sum(enum) / Enum.count(enum)   defp square(enum), do: (for x <- enum, do: x * x) end   IO.puts RC.root_mean_square(1..10)  
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Emacs_Lisp
Emacs Lisp
(defun rms (nums) (sqrt (/ (apply '+ (mapcar (lambda (x) (* x x)) nums)) (float (length nums)))))   (rms (number-sequence 1 10))
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Standard_ML
Standard ML
val debase64 = fn input => let   infix 2 Worb infix 2 Wandb fun (p Worb q ) = Word.orb (p,q); fun (p Wandb q ) = Word.andb (p,q);   fun decode #"/" = 0wx3F | decode #"+" = 0wx3E | decode c = if Char.isDigit c then Word.fromInt (ord c) + 0wx04 else if Char.isLower c then Word.fromInt (or...
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Tcl
Tcl
package require tcl 8.6 set data VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=   puts [binary decode base64 $data]
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Applesoft_BASIC
Applesoft BASIC
100 LET YY(1) = .16 110 XX(2) = .85:XY(2) = .04 120 YX(2) = - .04:YY(2) = .85 130 LET Y(2) = 1.6 140 XX(3) = .20:XY(3) = - .26 150 YX(3) = .23:YY(3) = .22 160 LET Y(3) = 1.6 170 XX(4) = - .15:XY(4) = .28 180 YX(4) = .26:YY(4) = .24 190 LET Y(4) = .44 200 HGR :I = PEEK (49234) 210 HC...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#BASIC256
BASIC256
# adjustable window altoght # call the subroutine with the altoght you want # it's possible to have a window that's large than your display call barnsley(800) end   subroutine barnsley(alto) graphsize alto / 2, alto color rgb(0, 255, 0)   f = alto / 10.6 c = alto / 4 - alto / 40 x = 0 : y = 0   ...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Erlang
Erlang
rms(Nums) -> math:sqrt(lists:foldl(fun(E,S) -> S+E*E end, 0, Nums) / length(Nums)).   rms([1,2,3,4,5,6,7,8,9,10]).
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#ERRE
ERRE
  PROGRAM ROOT_MEAN_SQUARE BEGIN N=10 FOR I=1 TO N DO S=S+I*I END FOR X=SQR(S/N) PRINT("Root mean square is";X) END PROGRAM  
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Visual_Basic_.NET
Visual Basic .NET
Module Module1   Sub Main() Dim data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=" Console.WriteLine(data) Console.WriteLine()   Dim decoded = Text.Encoding.ASCII.GetString(Convert.FromBase64String(data)) ...
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Vlang
Vlang
import encoding.base64   fn main() { msg := "Rosetta Code Base64 decode data task" println("Original : $msg") encoded := base64.encode_str(msg) println("\nEncoded  : $encoded") decoded := base64.decode_str(encoded) println("\nDecoded  : $decoded") }
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#BBC_BASIC
BBC BASIC
GCOL 2 : REM Green Graphics Color X=0 : Y=0 FOR I%=1 TO 100000 R%=RND(100) CASE TRUE OF WHEN R% == 1 NewX= 0  : NewY= .16 * Y WHEN R% < 9 NewX= .20 * X - .26 * Y : NewY= .23 * X + .22 * Y + 1.6 WHEN R% < 16 NewX=-.15 * X + .28 * Y : NewY= ....
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#C
C
  #include<graphics.h> #include<stdlib.h> #include<stdio.h> #include<time.h>   void barnsleyFern(int windowWidth, unsigned long iter){   double x0=0,y0=0,x1,y1; int diceThrow; time_t t; srand((unsigned)time(&t));   while(iter>0){ diceThrow = rand()%100;   if(diceThrow==0){ x1 = 0; y1 = 0.16*y0; }   e...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Euphoria
Euphoria
function rms(sequence s) atom sum if length(s) = 0 then return 0 end if sum = 0 for i = 1 to length(s) do sum += power(s[i],2) end for return sqrt(sum/length(s)) end function   constant s = {1,2,3,4,5,6,7,8,9,10} ? rms(s)
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#Wren
Wren
import "io" for Stdout import "/fmt" for Conv, Fmt import "/str" for Str   var alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"   var decode = Fn.new { |s| if (s == "") return s var d = "" for (b in s) { var ix = alpha.indexOf(b) if (ix >= 0) d = d + Fmt.swrite("$06b", i...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#C.23
C#
using System; using System.Diagnostics; using System.Drawing;   namespace RosettaBarnsleyFern { class Program { static void Main(string[] args) { const int w = 600; const int h = 600; var bm = new Bitmap(w, h); var r = new Random(); dou...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Excel
Excel
  =SQRT(SUMSQ($A1:$A10)/COUNT($A1:$A10))  
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#F.23
F#
let RMS (x:float list) : float = List.map (fun y -> y**2.0) x |> List.average |> System.Math.Sqrt   let res = RMS [1.0..10.0]
http://rosettacode.org/wiki/Base64_decode_data
Base64 decode data
See Base64 encode data. Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file. When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously...
#zkl
zkl
var [const] MsgHash=Import("zklMsgHash"), Curl=Import("zklCurl");   icon:=Curl().get("http://rosettacode.org/favicon.ico"); //-->(Data(4,331),693,0) icon=icon[0][icon[1],*]; // remove header iconEncoded:=MsgHash.base64encode(icon); iconDecoded:=MsgHash.base64decode(iconEncoded); File("rosettaCodeIcon.ico","wb").write(i...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#C.2B.2B
C++
  #include <windows.h> #include <ctime> #include <string>   const int BMP_SIZE = 600, ITERATIONS = static_cast<int>( 15e5 );   class myBitmap { public: myBitmap() : pen( NULL ), brush( NULL ), clr( 0 ), wid( 1 ) {} ~myBitmap() { DeleteObject( pen ); DeleteObject( brush ); DeleteDC( hdc ); Delete...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Factor
Factor
: root-mean-square ( seq -- mean ) [ [ sq ] map-sum ] [ length ] bi / sqrt ;
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Fantom
Fantom
class Main { static Float averageRms (Float[] nums) { if (nums.size == 0) return 0.0f Float sum := 0f nums.each { sum += it * it } return (sum / nums.size.toFloat).sqrt }   public static Void main () { a := [1f,2f,3f,4f,5f,6f,7f,8f,9f,10f] echo ("RMS Average of $a is: " + averageRms(a)...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Common_Lisp
Common Lisp
(defpackage #:barnsley-fern (:use #:cl #:opticl))   (in-package #:barnsley-fern)   (defparameter *width* 800) (defparameter *height* 800) (defparameter *factor* (/ *height* 13)) (defparameter *x-offset* (/ *width* 2)) (defparameter *y-offset* (/ *height* 10))   (defun f1 (x y) (declare (ignore x)) (values...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Forth
Forth
: rms ( faddr len -- frms ) dup >r 0e floats bounds do i f@ fdup f* f+ float +loop r> s>f f/ fsqrt ;   create test 1e f, 2e f, 3e f, 4e f, 5e f, 6e f, 7e f, 8e f, 9e f, 10e f, test 10 rms f. \ 6.20483682299543
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Fortran
Fortran
print *,sqrt( sum(x**2)/size(x) )
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#D
D
#!/usr/bin/env dub /+ dub.sdl: dependency "dlib" version="~>0.21.0" +/ import std.random;   import dlib.image;   void main() { enum WIDTH = 640; enum HEIGHT = 640; enum ITERATIONS = 2E6;   float x = 0.0f; float y = 0.0f;   auto rng = Random(unpredictableSeed); auto color = Color4f(0.0f, 1.0f, 0.0f); auto img =...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#FreeBASIC
FreeBASIC
  ' FB 1.05.0 Win64   Function QuadraticMean(array() As Double) As Double Dim length As Integer = Ubound(array) - Lbound(array) + 1 Dim As Double sum = 0.0 For i As Integer = LBound(array) To UBound(array) sum += array(i) * array(i) Next Return Sqr(sum/length) End Function   Dim vector(1 To 10) As Double ...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Delphi
Delphi
unit Unit1;   interface   uses Windows, SysUtils, Graphics, Forms, Controls, Classes, ExtCtrls;   type TForm1 = class(TForm) PaintBox1: TPaintBox; procedure FormPaint(Sender: TObject); private { Private declarations } public { Public declarations } end;   var Form1: TForm1;   implementation ...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Futhark
Futhark
  import "futlib/math"   fun main(as: [n]f64): f64 = f64.sqrt ((reduce (+) 0.0 (map (**2.0) as)) / f64(n))  
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#GEORGE
GEORGE
  1, 10 rep (i) i i | (v) ; 0 1, 10 rep (i) i dup mult + ] 10 div sqrt print  
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#EasyLang
EasyLang
color 060 for i range 200000 r = randomf if r < 0.01 nx = 0 ny = 0.16 * y elif r < 0.08 nx = 0.2 * x - 0.26 * y ny = 0.23 * x + 0.22 * y + 1.6 elif r < 0.15 nx = -0.15 * x + 0.28 * y ny = 0.26 * x + 0.24 * y + 0.44 else nx = 0.85 * x + 0.04 * y ny = -0.04 * x + 0.85 * y + 1.6 ...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Emacs_Lisp
Emacs Lisp
; Barnsley fern   (defun make-array (size) "Create an empty array with size*size elements." (setq m-array (make-vector size nil)) (dotimes (i size) (setf (aref m-array i) (make-vector size 0))) m-array)   (defun barnsley-next (p) "Return the next Barnsley fern coordinates." (let ((r (random 100)) ...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Go
Go
package main   import ( "fmt" "math" )   func main() { const n = 10 sum := 0. for x := 1.; x <= n; x++ { sum += x * x } fmt.Println(math.Sqrt(sum / n)) }
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Groovy
Groovy
def quadMean = { list -> list == null \ ? null \  : list.empty \ ? 0 \  : ((list.collect { it*it }.sum()) / list.size()) ** 0.5 }
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#F.23
F#
  open System.Drawing   let (|F1|F2|F3|F4|) r = if r < 0.01 then F1 else if r < 0.08 then F3 else if r < 0.15 then F4 else F2   let barnsleyFernFunction (x, y) = function | F1 -> (0.0, 0.16*y) | F2 -> ((0.85*x + 0.04*y), (-0.04*x + 0.85*y + 1.6)) | F3 -> ((0.2*x - 0.26*y), (0.23*x + 0.22*y +...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Haskell
Haskell
main = print $ mean 2 [1 .. 10]
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#HicEst
HicEst
sum = 0 DO i = 1, 10 sum = sum + i^2 ENDDO WRITE(ClipBoard) "RMS(1..10) = ", (sum/10)^0.5
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#11l
11l
T SMA [Float] data sum = 0.0 index = 0 n_filled = 0 Int period   F (period) .period = period .data = [0.0] * period   F add(v) .sum += v - .data[.index] .data[.index] = v .index = (.index + 1) % .period .n_filled = min(.period, .n_filled + 1) R .sum / .n_fi...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Forth
Forth
  s" SDL2" add-lib \c #include <SDL2/SDL.h> c-function sdl-init SDL_Init n -- n c-function sdl-quit SDL_Quit -- void c-function sdl-createwindow SDL_CreateWindow a n n n n n -- a c-function sdl-createrenderer SDL_CreateRenderer a n n -- a c-function sdl-setdrawcolor SDL_SetRenderDrawColor a n n n n -- n c-function ...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Icon_and_Unicon
Icon and Unicon
procedure main() every put(x := [], 1 to 10) writes("x := [ "); every writes(!x," "); write("]") write("Quadratic mean:",q := qmean!x) end
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#360_Assembly
360 Assembly
* Averages/Simple moving average 26/08/2015 AVGSMA CSECT USING AVGSMA,R12 LR R12,R15 ST R14,SAVER14 ZAP II,=P'0' ii=0 LA R7,1 LH R3,NA SRA R3,1 na/2 LOOPA CR R7,R3 do i=1 to na/2 ...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Fortran
Fortran
  !Generates an output file "plot.dat" that contains the x and y coordinates !for a scatter plot that can be visualized with say, GNUPlot program BarnsleyFern implicit none   double precision :: p(4), a(4), b(4), c(4), d(4), e(4), f(4), trx, try, prob integer :: itermax, i   !The probabilites and coefficients can be m...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Io
Io
rms := method (figs, (figs map(** 2) reduce(+) / figs size) sqrt)   rms( Range 1 to(10) asList ) println
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#J
J
rms=: (+/ % #)&.:*:
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#Ada
Ada
generic Max_Elements : Positive; type Number is digits <>; package Moving is procedure Add_Number (N : Number); function Moving_Average (N : Number) return Number; function Get_Average return Number; end Moving;
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#FreeBASIC
FreeBASIC
' version 10-10-2016 ' compile with: fbc -s console   Sub barnsley(height As UInteger)   Dim As Double x, y, xn, yn Dim As Double f = height / 10.6 Dim As UInteger offset_x = height \ 4 - height \ 40 Dim As UInteger n, r   ScreenRes height \ 2, height, 32   For n = 1 To height * 50   r = Int(Rnd * 100) ...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Java
Java
public class RootMeanSquare {   public static double rootMeanSquare(double... nums) { double sum = 0.0; for (double num : nums) sum += num * num; return Math.sqrt(sum / nums.length); }   public static void main(String[] args) { double[] nums = {1.0, 2.0, 3.0, 4.0,...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#JavaScript
JavaScript
function root_mean_square(ary) { var sum_of_squares = ary.reduce(function(s,x) {return (s + x*x)}, 0); return Math.sqrt(sum_of_squares / ary.length); }   print( root_mean_square([1,2,3,4,5,6,7,8,9,10]) ); // ==> 6.2048368229954285
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#ALGOL_68
ALGOL 68
MODE SMAOBJ = STRUCT( LONG REAL sma, LONG REAL sum, INT period, REF[]LONG REAL values, INT lv );   MODE SMARESULT = UNION ( REF SMAOBJ # handle #, LONG REAL # sma #, REF[]LONG REAL # values # );   MODE SMANEW = INT, SMAFREE = STRUCT(REF SMAOBJ free obj), SMAVALUES = STRUCT(REF SMAOBJ values o...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Frink
Frink
  g = new graphics g.backgroundColor[0,0,0] // black g.color[0,0.5,0] // green   x = 0 y = 0   for i = 1 to 100000 { g.fillEllipseCenter[x*10,y*-10,0.25,0.25] z = random[1, 100] if z == 1 { xn = 0 yn = 0.16 * y } if z >= 2 and z <= 86 { xn = 0.85 * x + 0.04 * y yn = -0.04 * ...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#jq
jq
def rms: length as $length | if $length == 0 then null else map(. * .) | add | sqrt / $length end ;
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Julia
Julia
sqrt(sum(A.^2.) / length(A))
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#AutoHotkey
AutoHotkey
MsgBox % MovingAverage(5,3) ; 5, averaging length <- 3 MsgBox % MovingAverage(1) ; 3 MsgBox % MovingAverage(-3) ; 1 MsgBox % MovingAverage(8) ; 2 MsgBox % MovingAverage(7) ; 4   MovingAverage(x,len="") { ; for integers (faster) Static Static sum:=0, n:=0, m:=10 ; default averaging length = 10 If (l...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#F.C5.8Drmul.C3.A6
Fōrmulæ
  # Put this into a new file 'fern.gmic' and invoke it from the command line, like this: # $ gmic fern.gmic -barnsley_fern   barnsley_fern : 1024,2048 -skip {" f1 = [ 0,0,0,0.16 ]; g1 = [ 0,0 ]; f2 = [ 0.2,-0.26,0.23,0.22 ]; g2 = [ 0,1.6 ]; f3 = [ -0.15,0.28,0.26,0.24 ]; g3 = [ 0,0.44 ]...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#K
K
  rms:{_sqrt (+/x^2)%#x} rms 1+!10 6.204837  
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Kotlin
Kotlin
// version 1.0.5-2   fun quadraticMean(vector: Array<Double>) : Double { val sum = vector.sumByDouble { it * it } return Math.sqrt(sum / vector.size) }   fun main(args: Array<String>) { val vector = Array(10, { (it + 1).toDouble() }) print("Quadratic mean of numbers 1 to 10 is ${quadraticMean(vector)}")...
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#AWK
AWK
#!/usr/bin/awk -f # Moving average over the first column of a data file BEGIN { P = 5; }   { x = $1; i = NR % P; MA += (x - Z[i]) / P; Z[i] = x; print MA; }
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#G.27MIC
G'MIC
  # Put this into a new file 'fern.gmic' and invoke it from the command line, like this: # $ gmic fern.gmic -barnsley_fern   barnsley_fern : 1024,2048 -skip {" f1 = [ 0,0,0,0.16 ]; g1 = [ 0,0 ]; f2 = [ 0.2,-0.26,0.23,0.22 ]; g2 = [ 0,1.6 ]; f3 = [ -0.15,0.28,0.26,0.24 ]; g3 = [ 0,0.44 ]...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Lasso
Lasso
define rms(a::staticarray)::decimal => { return math_sqrt((with n in #a sum #n*#n) / decimal(#a->size)) } rms(generateSeries(1,10)->asStaticArray)
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Liberty_BASIC
Liberty BASIC
' [RC] Averages/Root mean square   SourceList$ ="1 2 3 4 5 6 7 8 9 10"   ' If saved as an array we'd have to have a flag for last data. ' LB has the very useful word$() to read from delimited strings. ' The default delimiter is a space character, " ".   SumOfSquares =0 n ...
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#BBC_BASIC
BBC BASIC
MAXPERIOD = 10 FOR n = 1 TO 5 PRINT "Number = ";n TAB(12) " SMA3 = ";FNsma(n,3) TAB(30) " SMA5 = ";FNsma(n,5) NEXT FOR n = 5 TO 1 STEP -1 PRINT "Number = ";n TAB(12) " SMA3 = ";FNsma(n,3) TAB(30) " SMA5 = ";FNsma(n,5) NEXT END   DEF FNsma(number, period%) ...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#gnuplot
gnuplot
  ## Barnsley fern fractal 2/17/17 aev reset fn="BarnsleyFernGnu"; clr='"green"'; ttl="Barnsley fern fractal" dfn=fn.".dat"; ofn=fn.".png"; set terminal png font arial 12 size 640,640 set print dfn append set output ofn unset border; unset xtics; unset ytics; unset key; set size square set title ttl font "Arial:Bold,1...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Logo
Logo
to rms :v output sqrt quotient (apply "sum map [? * ?] :v) count :v end   show rms iseq 1 10
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Lua
Lua
function sumsq(a, ...) return a and a^2 + sumsq(...) or 0 end function rms(t) return (sumsq(unpack(t)) / #t)^.5 end   print(rms{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#BQN
BQN
SMA ← {(+´÷≠)¨(1↓𝕨↑↑𝕩)∾<˘𝕨↕𝕩} v ← (⊢∾⌽)1+↕5 •Show 5 SMA v SMA2 ← { 𝕊 size: nums ← ⟨⟩ sum ← 0 { nums ∾↩ 𝕩 gb ← {(≠nums)≤size ? 0 ; a←⊑nums, nums↩1↓nums, a} sum +↩ 𝕩 - gb sum ÷ ≠nums } } fun ← SMA2 5 Fun¨ v
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Go
Go
package main   import ( "image" "image/color" "image/draw" "image/png" "log" "math/rand" "os" )   // values from WP const ( xMin = -2.1820 xMax = 2.6558 yMin = 0. yMax = 9.9983 )   // parameters var ( width = 200 n = int(1e6) c = color.RGBA{34, 139, 34, 25...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Maple
Maple
y := [ seq(1..10) ]: RMS := proc( x ) return sqrt( Statistics:-Mean( x ^~ 2 ) ); end proc: RMS( y );  
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Mathematica_.2F_Wolfram_Language
Mathematica / Wolfram Language
RootMeanSquare@Range[10]
http://rosettacode.org/wiki/Babbage_problem
Babbage problem
Charles Babbage, looking ahead to the sorts of problems his Analytical Engine would be able to solve, gave this example: What is the smallest positive integer whose square ends in the digits 269,696? — Babbage, letter to Lord Bowden, 1837; see Hollingdale and Tootill, Electronic Computers, second edition, 1970, p....
#11l
11l
V n = 1 L n ^ 2 % 1000000 != 269696 n++ print(n)
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#Bracmat
Bracmat
( ( I = buffer . (new$=):?freshEmptyBuffer & ' ( buffer avg . ( avg = L S n . 0:?L:?S & whl ' ( !arg:%?n ?arg & !n+!S:?S & 1+!L:?L ) ...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Groovy
Groovy
import javafx.animation.AnimationTimer import javafx.application.Application import javafx.scene.Group import javafx.scene.Scene import javafx.scene.image.ImageView import javafx.scene.image.WritableImage import javafx.scene.paint.Color import javafx.stage.Stage   class BarnsleyFern extends Application {   @Overrid...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#MATLAB
MATLAB
function rms = quadraticMean(list) rms = sqrt(mean(list.^2)); end
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#Maxima
Maxima
L: makelist(i, i, 10)$   rms(L) := sqrt(lsum(x^2, x, L)/length(L))$   rms(L), numer; /* 6.204836822995429 */
http://rosettacode.org/wiki/Babbage_problem
Babbage problem
Charles Babbage, looking ahead to the sorts of problems his Analytical Engine would be able to solve, gave this example: What is the smallest positive integer whose square ends in the digits 269,696? — Babbage, letter to Lord Bowden, 1837; see Hollingdale and Tootill, Electronic Computers, second edition, 1970, p....
#360_Assembly
360 Assembly
  * Find the lowest positive integer whose square ends in 269696 * The logic of the assembler program is simple : * loop for i=524 step 2 * if (i*i modulo 1000000)=269696 then leave loop * next i * output 'Solution is: i=' i ' (i*i=' i*i ')' BABBAGE CSECT ...
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#Brat
Brat
  SMA = object.new   SMA.init = { period | my.period = period my.list = [] my.average = 0 }   SMA.prototype.add = { num | true? my.list.length >= my.period { my.list.deq }   my.list << num my.average = my.list.reduce(:+) / my.list.length }   sma3 = SMA.new 3 sma5 = SMA.new 5 [1, 2, 3, 4, 5, 5, 4, 3, 2, ...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#Haskell
Haskell
import Data.List (scanl') import Diagrams.Backend.Rasterific.CmdLine import Diagrams.Prelude import System.Random   type Pt = (Double, Double)   -- Four affine transformations used to produce a Barnsley fern. f1, f2, f3, f4 :: Pt -> Pt f1 (x, y) = ( 0, 0.16 * y) f2 (x, y) = ( 0.85 * x...
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#MAXScript
MAXScript
  fn RMS arr = ( local sumSquared = 0 for i in arr do sumSquared += i^2 return (sqrt (sumSquared/arr.count as float)) )  
http://rosettacode.org/wiki/Averages/Root_mean_square
Averages/Root mean square
Task[edit] 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: x r m s = x 1 2 + x 2 2 + ⋯ + x ...
#min
min
(dup *) :sq ('sq map sum) :sum-sq (('sum-sq 'size) => cleave / sqrt) :rms   (1 2 3 4 5 6 7 8 9 10) rms puts!
http://rosettacode.org/wiki/Babbage_problem
Babbage problem
Charles Babbage, looking ahead to the sorts of problems his Analytical Engine would be able to solve, gave this example: What is the smallest positive integer whose square ends in the digits 269,696? — Babbage, letter to Lord Bowden, 1837; see Hollingdale and Tootill, Electronic Computers, second edition, 1970, p....
#Ada
Ada
-- The program is written in the programming language Ada. The name "Ada" -- has been chosen in honour of your friend, -- Augusta Ada King-Noel, Countess of Lovelace (née Byron). -- -- This is an program to search for the smallest integer X, such that -- (X*X) mod 1_000_000 = 269_696. -- -- In the Ada language,...
http://rosettacode.org/wiki/Averages/Simple_moving_average
Averages/Simple moving average
Computing the simple moving average of a series of numbers. Task[edit] Create a stateful function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far. Description A simple moving average is a method for computing an avera...
#C
C
#include <stdio.h> #include <stdlib.h> #include <stdarg.h>   typedef struct sma_obj { double sma; double sum; int period; double *values; int lv; } sma_obj_t;   typedef union sma_result { sma_obj_t *handle; double sma; double *values; } sma_result_t;   enum Action { SMA_NEW, SMA_FREE, SMA_VALUES, SMA_AD...
http://rosettacode.org/wiki/Barnsley_fern
Barnsley fern
A Barnsley fern is a fractal named after British mathematician Michael Barnsley and can be created using an iterated function system (IFS). Task Create this fractal fern, using the following transformations: ƒ1   (chosen 1% of the time) xn + 1 = 0 yn + 1 = 0.16 yn ƒ2   (chosen 85% of the time) ...
#IS-BASIC
IS-BASIC
100 PROGRAM "Fern.bas" 110 RANDOMIZE 120 SET VIDEO MODE 1:SET VIDEO COLOR 0:SET VIDEO X 40:SET VIDEO Y 27 130 OPEN #101:"video:" 140 DISPLAY #101:AT 1 FROM 1 TO 27 150 SET PALETTE BLACK,GREEN 160 LET MX=16000:LET X,Y=0 170 FOR N=1 TO MX 180 LET P=RND(100) 190 SELECT CASE P 200 CASE IS<=1 210 LET NX=0:LET NY=...