21 lines
538 B
Text
21 lines
538 B
Text
local fmt = require "fmt"
|
|
|
|
local multiplier = |n1, n2| -> (|m| -> n1 * n2 * m)
|
|
|
|
local function ordered_collection()
|
|
local x = 2.0
|
|
local xi = 0.5
|
|
local y = 4.0
|
|
local yi = 0.25
|
|
local z = x + y
|
|
local zi = 1.0 / ( x + y )
|
|
return {x, y, z}, {xi, yi, zi}
|
|
end
|
|
|
|
local oc1, oc2 = ordered_collection()
|
|
for i = 1, 3 do
|
|
local x = oc1[i]
|
|
local y = oc2[i]
|
|
local m = 0.5 -- rather than 1 to compare with first-class functions task
|
|
fmt.print("%0.1g * %f * %0.1g = %0.1g", x, y, m, multiplier(x, y)(m))
|
|
end
|