1: include "std"; 2: fun mid(a:int, b:int):int = 3: { 4: val c = (a + b) / 2; 5: return c; 6: } 7: print (mid(2,4)); print "\n";
Functions in Felix may not have any side effects, except for diagnostic outputs. Note however that functions may modify their own private data, that is, may contain and mutate local variables.
Whilst in the above example the return type of the function is clearly given, it is not necessary, as illustrated by the next example:
1: include "std"; 2: fun mid(a:int, b:int) = 3: { 4: val c = (a + b) / 2; 5: return c; 6: } 7: print (mid(2,4)); print "\n";