Function
Background
Section titled “Background”Given a file named “pen.json” with:
{ "type": "library", "dependencies": {}}Define a function
Section titled “Define a function”Given a file named “Foo.pen” with:
f = \(x number) number { x}When I run pen build
Then the exit status should be 0.
Call a function with no argument
Section titled “Call a function with no argument”Given a file named “Foo.pen” with:
f = \() number { f()}When I run pen build
Then the exit status should be 0.
Call a function with an argument
Section titled “Call a function with an argument”Given a file named “Foo.pen” with:
f = \(x number) number { f(x)}When I run pen build
Then the exit status should be 0.
Call a function with two arguments
Section titled “Call a function with two arguments”Given a file named “Foo.pen” with:
f = \(x number, y number) number { f(x, y)}When I run pen build
Then the exit status should be 0.
Define a closure
Section titled “Define a closure”Given a file named “Foo.pen” with:
f = \(x number) \(number) number { \(y number) number { x + y }}When I run pen build
Then the exit status should be 0.