Accumulator factory: Difference between revisions

Added 11l
(Added 11l)
Line 31:
Where it is not possible to hold exactly to the constraints above, describe the deviations.
<br><br>
 
=={{header|11l}}==
<lang 11l>F accumulator(n)
T Accumulator
Float s
F (Float n)
.s = n
F ()(Float n)
.s += n
R .s
R Accumulator(n)
 
V x = accumulator(1)
print(x(5))
print(x(2.3))
 
V x2 = accumulator(3)
print(x2(5))
print(x2(3.3))
print(x2(0))</lang>
 
{{out}}
<pre>
6
8.3
8
11.3
11.3
</pre>
 
=={{header|8th}}==
1,453

edits