# Functions

## Defining a function

Body of a function consists of two parts, the first part (** block {}** or

**) - normally consists of logic**

`begin ... end`

*(flow conditions, variable declarations, etc.)*, and the second part (

**) usually defines the return value of your function.**

`with ...`

`const availableSupply: nat = 15n;`

const totalSupply: nat = 100n;

function calculatePrice(const available: nat; const total: nat): nat is

begin

const price: nat = total / available

end with price

const price: nat = calculatePrice(availableSupply, totalSupply);

### Functions without an explicit body (shorter syntax)

A short hand syntax for the same function as above can inline the price calculation directly into the return statement. While this approach can have it's benefits, it can decrease readability.

`const availableSupply: nat = 15n;`

const totalSupply: nat = 100n;

function calculatePrice(const available: nat; const total: nat): nat is

block { skip } with total / available

const price: nat = calculatePrice(availableSupply, totalSupply);