Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
13
Task/Forward-difference/Nim/forward-difference.nim
Normal file
13
Task/Forward-difference/Nim/forward-difference.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
proc dif(s): seq[int] =
|
||||
result = newSeq[int](s.len-1)
|
||||
for i, x in s[1..s.high]:
|
||||
result[i] = x - s[i]
|
||||
|
||||
proc difn(s, n): seq[int] =
|
||||
if n > 0: difn(dif(s), n-1)
|
||||
else: s
|
||||
|
||||
const s = @[90, 47, 58, 29, 22, 32, 55, 5, 55, 73]
|
||||
echo difn(s, 0)
|
||||
echo difn(s, 1)
|
||||
echo difn(s, 2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue