Averages/Simple moving average: Difference between revisions

m
(Added Easylang)
imported>Arakov
(2 intermediate revisions by 2 users not shown)
Line 1,324:
 
=={{header|Elena}}==
ELENA 56.0x :
<syntaxhighlight lang="elena">import system'routines;
import system'collections;
Line 1,347:
count =>
0 { ^0.0r }
:! {
if (count > thePeriod)
{
theList.removeAt:(0);
count := thePeriod
Line 1,361:
}
}
 
// --- Program ---
 
public program()
{
var SMA3 := SMA.new:(3);
var SMA5 := SMA.new:(5);
 
for (int i := 1,; i <= 5,; i += 1) {
console.printPaddingRight(30, "sma3 + ", i, " = ", SMA3.append:(i));
console.printLine("sma5 + ", i, " = ", SMA5.append:(i))
};
 
for (int i := 5,; i >= 1,; i -= 1) {
console.printPaddingRight(30, "sma3 + ", i, " = ", SMA3.append:(i));
console.printLine("sma5 + ", i, " = ", SMA5.append:(i))
};
Line 4,885 ⟶ 4,887:
{{trans|Go}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var sma = Fn.new { |period|
Line 4,908 ⟶ 4,910:
for (x in [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) {
Fmt.precision = 3
SystemFmt.print("%(Fmt.f(5,$5f x)) $5f %(Fmt.f(5$5f", x, sma3.call(x))) %(Fmt.f(5, sma5.call(x)))")
}</syntaxhighlight>
 
Anonymous user