Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,28 @@
import queues
proc simplemovingaverage(period: int): auto =
assert period > 0
var
summ, n = 0.0
values = initQueue[float]()
for i in 1..period:
values.add(0)
proc sma(x: float): float =
values.add(x)
summ += x - values.dequeue()
n = min(n+1, float(period))
result = summ / n
return sma
var sma = simplemovingaverage(3)
for i in 1..5: echo sma(float(i))
for i in countdown(5,1): echo sma(float(i))
echo ""
var sma2 = simplemovingaverage(5)
for i in 1..5: echo sma2(float(i))
for i in countdown(5,1): echo sma2(float(i))