Averages/Root mean square: Difference between revisions

Content added Content deleted
(→‎{{header|AppleScript}}: Added straightforward solution and loopless integer range alternative.)
Line 228: Line 228:
===Functional===
===Functional===
{{Trans|JavaScript}}( ES6 version )
{{Trans|JavaScript}}( ES6 version )
<syntaxhighlight lang="applescript">-- rootMeanSquare :: [Num] -> Real
<syntaxhighlight lang="applescript">--------------------- ROOT MEAN SQUARE -------------------

-- rootMeanSquare :: [Num] -> Real
on rootMeanSquare(xs)
on rootMeanSquare(xs)
script
script
Line 240: Line 242:




-- TEST -----------------------------------------------------------------------
--------------------------- TEST -------------------------
on run
on run
Line 249: Line 251:




-- GENERIC FUNCTIONS ----------------------------------------------------------
-------------------- GENERIC FUNCTIONS -------------------


-- foldl :: (a -> b -> a) -> a -> [b] -> a
-- foldl :: (a -> b -> a) -> a -> [b] -> a
Line 277: Line 279:
<pre>6.204836822995</pre>
<pre>6.204836822995</pre>
----
----

===Straightforward===
===Straightforward===
<syntaxhighlight lang="applescript">on rootMeanSquare(listOfNumbers)
<syntaxhighlight lang="applescript">on rootMeanSquare(listOfNumbers)