# Expressions

Expressions in Midio allow you to write small snippets of logic directly inside function inputs. They can be used anywhere a function input is editable and are a powerful way to perform computations or dynamically construct values inline.

<figure><img src="https://1896308808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdFpuRAnTVYgmlCXLLou%2Fuploads%2FxwSKfkgHLXhcylcIMubo%2FMidio.png?alt=media&#x26;token=c77d29b3-f0c3-4e82-ab4d-dacd34b11064" alt=""><figcaption></figcaption></figure>

### What You Can Do with Expressions

Expressions support many of the constructs you'd expect from a general-purpose language:

* **Unary and binary operators**: Use operators like `+`, `-`, `*`, `/`, `!`, and more to perform arithmetic and logical operations.
* **Ternary operator**: Use the `condition ? valueIfTrue : valueIfFalse` form to choose between values based on a condition.
* [Perform SQL like queries on lists](https://docs.midio.com/midio-docs/guides/expressions/queries)
* **Literals**: You can use basic data literals including numbers (`42`), strings (`"hello"`), booleans (`true`, `false`), objects (`{a: 1}`), and lists (`[1, 2, 3]`).
* **Use** [**Local Variables**](https://docs.midio.com/midio-docs/reference/the-midio-language/local-variables)**:** Local variables can be retrieved by prefixing their name with `@`, e.g. `@myVariable`.
* **Inputs**: Add inputs to your expression by simply writing an identifier name (e.g., `inputValue`). This adds an additional input property underneath the input you placed the expression in.
* **Indexing and calls**: Use `[index]` to access list or object properties and `()` to call functions. *Note: Functions must currently be passed in as inputs to be called in expressions.*
* **String interpolation**: Embed expressions inside strings using `${...}` syntax. For example: `"Hello, ${name}!"`.
* Call various builtin math functions, like math.cos(1.0), og math.random(0, 10). Following is a list of all builtin functions:
  * math.is\_nan(x)
  * math.is\_finite(x)
  * math.is\_infinite(x)
  * math.is\_normal(x)
  * math.cos(angle)
  * math.sin(angle)
  * math.tan(angle)
  * math.acos(x)
  * math.asin(x)
  * math.atan(x)
  * math.atan2(y, x)
  * math.cosh(x)
  * math.sinh(x)
  * math.tanh(x)
  * math.acosh(x)
  * math.asinh(x)
  * math.atanh(x)
  * math.ln(x)
  * math.log2(x)
  * math.log10(x)
  * math.log(base, x)
  * math.exp(x)
  * math.exp2(x)
  * math.pow(base, exponent)
  * math.sqrt(x)
  * math.cbrt(x)
  * math.abs(x)
  * math.hypot(x, y)
  * math.random()
  * math.min(a, b)
  * math.max(a, b)
  * math.clamp(x, min\_val, max\_val)
  * math.lerp(a, b, t)
  * math.sign(x)
  * math.floor(x)
  * math.ceil(x)
  * math.round(x)
  * math.trunc(x)
  * math.fract(x)

### Limitations

Expressions currently cannot be used directly inside **object literals**—this will be added in a future update. See the [working with data](https://docs.midio.com/midio-docs/guides/working-with-data) guide for more information about how you can work around this limitation for now.
