Averages/Simple moving average: Difference between revisions

Content added Content deleted
(→‎{{header|D}}: replace _if_ statement with conditional expressions)
m (→‎{{header|D}}: Readability)
Line 298: Line 298:
index = (index + 1) % period ;
index = (index + 1) % period ;
sum += ( v - drop ) ;
sum += ( v - drop ) ;
filled = filled >= period ? period : filled + 1 ;
filled = (filled >= period) ? period : filled + 1 ;
return sum / filled ;
return sum / filled ;
}
}