Skip to content

Latest commit

 

History

History
27 lines (24 loc) · 2.37 KB

87-functional-addition.md

File metadata and controls

27 lines (24 loc) · 2.37 KB

Problem:

Create a function add(n)/Add(n) which returns a function that always adds n to any number

Note for Java: the return type and methods have not been provided to make it a bit more challenging.

var addOne = add(1);
addOne(3); // 4

var addThree = add(3); addThree(3); // 6

add_one = add(1)
add_one(3)  # 4

add_three = add(3)
add_three(3) # 6
addOne = add 1
addOne 3 `shouldBe` 4
addOne = add 1
addOne 3 # 4
addOne = add(1)
addOne(3) // 4
Func<double, double> AddOne = Kata.Add(1);
AddOne(3) => 4
...returnType addOne = Kata.add(1);
addOne.method(3) => 4
var addOne = Add(1)
addOne(3) // 4

Solution