17 lines
348 B
Text
17 lines
348 B
Text
|
|
local fmt = require "fmt"
|
||
|
|
|
||
|
|
local fs = |f, s| -> s:mapped(|e| -> f(e))
|
||
|
|
local f1 = |n| -> 2 * n
|
||
|
|
local f2 = |n| -> n * n
|
||
|
|
|
||
|
|
local partial = |f, g| -> (|x| -> f(g, x))
|
||
|
|
|
||
|
|
local ss = {{0, 1, 2, 3}, {2, 4, 6, 8}}
|
||
|
|
for ss as s do
|
||
|
|
local fsf1 = partial(fs, f1)
|
||
|
|
local fsf2 = partial(fs, f2)
|
||
|
|
fmt.lprint(fsf1(s))
|
||
|
|
fmt.lprint(fsf2(s))
|
||
|
|
print()
|
||
|
|
end
|