# Function Calls

Functions are packets of statements that can be used repeatedly. They can accept any number of inputs and can return any number of outputs.

The name of a function must be a valid identifier. If a function name is the same as a variable name, the variable name takes precedence. Similarly, if a user-defined function and built-in function have the same name, the user-defined function takes precedence.

`my_function(input1, input2, …, inputN)`

If a function can be called
without inputs, the ()’s are optional.`sqrt(1+b/3*5^2) % assuming b is a valid variable`

If the number of inputs passed to a function does not match the number expected by that function, an error occurs.

`sum(sqrt(1)+sqrt(2))`

It can also be assigned to a
variable.`output = sqrt(1)`

```
[out1, out2] = f(in1, in2)
function [len,first] = info(x)
len = length(x);
first = x(1);
end
[a,b] = info([4,8,2,9])
```

Unlike single return function calls, multi-return function calls cannot be directly combined with other operators.

If a function returns more outputs than are assigned, the remainder is ignored. If a function returns fewer outputs than are assigned, an error occurs.

```
myfunc('hello','goodbye')
myfunc hello goodbye
```

OML language has many built-in functions that are directly callable. These will be cataloged in a separate document. You can also define you own functions (see Function Definitions).