RosettaCodeData/Task/Function-composition/Wren/function-composition.wren

8 lines
187 B
Plaintext

var compose = Fn.new { |f, g| Fn.new { |x| f.call(g.call(x)) } }
var double = Fn.new { |x| 2 * x }
var addOne = Fn.new { |x| x + 1 }
System.print(compose.call(double, addOne).call(3))