Passing arguments and returning values
When we design programs, it is customary to think about allowing users to define input variables and choose what to receive in response; that is why Bosque allows including parameters and specifying a return type in the definition of a custom entrypoint.
As we can see in the following script, we have a function that receives two integer parameters which will be multiplied and divided, returning a float value:
entrypoint function triangleArea(base: Int, height: Int): Float64 { return ( base * height ) / 2; }
The structure of a custom entry point can be summarized in the following graphic:
Let's see an example. We will write a program that calculates the number in the nth position in the Fibonacci series using a recursive function.
First, we have to write a simple Fibonacci generator function:
recursive function fibonacciNumber(n: Int): Int { ...