Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
21
Task/Forward-difference/Pluto/forward-difference.pluto
Normal file
21
Task/Forward-difference/Pluto/forward-difference.pluto
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
local fmt = require "fmt"
|
||||
require "table2"
|
||||
|
||||
local function forward_diff(a, order)
|
||||
assert(order >= 0 and order % 1 == 0, "Order must be a non-negative integer.")
|
||||
if #a == 0 then return end
|
||||
io.write(" 0: ")
|
||||
fmt.tprint("%5d", a)
|
||||
if #a == 1 then return end
|
||||
if order == 0 then return end
|
||||
for o = 1, order do
|
||||
local b = table.rep(#a - 1, 0)
|
||||
for i = 1, #b do b[i] = a[i + 1] - a[i] end
|
||||
io.write($" {o}: ")
|
||||
fmt.tprint("%5d", b)
|
||||
if #b == 1 then return end
|
||||
a = b
|
||||
end
|
||||
end
|
||||
|
||||
forward_diff({90, 47, 58, 29, 22, 32, 55, 5, 55, 73}, 9)
|
||||
Loading…
Add table
Add a link
Reference in a new issue