Averages/Arithmetic mean: Difference between revisions

no edit summary
m (Moved and simplified C#.)
No edit summary
Line 399:
return sum / 1.max(count)
}</lang>
 
=={{header|Elena}}==
<lang elena>#define basic'* = std'basic'*.
#define ctrl'* = std'patterns'*.
 
#class MeanAction
{
#field theValue.
#field theCount.
#role Empty
{
#method int'get = 0.
#method evaluate : aValue
[
theValue := basic'Real::0.
theCount := basic'Integer::0.
#shift.
self evaluate:aValue.
]
}
#method new
[
#shift Empty.
]
#method int'get = theValue / theCount.
#method evaluate : aValue
[
theCount += 1.
theValue += aValue.
]
}
 
#symbol Program =>
[
#var anAction := MeanAction.
ctrl'Control run &list:(1, 2, 3, 4, 5, 6, 7, 8) &foreach:anAction.
'program'Output << anAction int.
].
</lang>
 
=={{header|Erlang}}==
Anonymous user