> ## Documentation Index
> Fetch the complete documentation index at: https://errand.nuvrel.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Functions

> Built-in functions available in expressions.

Errand provides a set of built-in functions that you can use in any expression: computed block values, task conditions, working directories, and command strings.

## Categories

<CardGroup cols={2}>
  <Card title="String" icon="font" href="/functions/string/chomp">
    Manipulate and transform strings.
  </Card>

  <Card title="Number" icon="hashtag" href="/functions/number/max">
    Arithmetic and parsing functions.
  </Card>

  <Card title="Collection" icon="layer-group" href="/functions/collection/coalesce">
    Work with lists, sets, and maps.
  </Card>

  <Card title="Encoding" icon="code" href="/functions/encoding/base64encode">
    Encode and decode data formats.
  </Card>

  <Card title="Crypto" icon="lock" href="/functions/crypto/sha256">
    Hash values for integrity and cache keys.
  </Card>

  <Card title="Filesystem" icon="folder-open" href="/functions/filesystem/file">
    Read files, resolve paths, and discover files.
  </Card>

  <Card title="Datetime" icon="calendar" href="/functions/datetime/formatdate">
    Format dates and timestamps.
  </Card>

  <Card title="Regex" icon="magnifying-glass" href="/functions/regex/regex">
    Pattern matching and extraction.
  </Card>

  <Card title="UUID" icon="fingerprint" href="/functions/uuid/uuid">
    Generate unique identifiers.
  </Card>

  <Card title="Conversion" icon="arrows-left-right" href="/functions/conversion/tostring">
    Convert values between types.
  </Card>

  <Card title="Environment" icon="terminal" href="/functions/environment/env">
    Read environment variables.
  </Card>

  <Card title="Runtime" icon="microchip" href="/functions/runtime/os">
    Detect the current platform.
  </Card>
</CardGroup>

## Using functions

Call a function by name with parentheses:

```hcl theme={null}
computed "image_tag" {
  expression = lower(replace(var.branch, "/", "-"))
}
```

Functions can be nested:

```hcl theme={null}
computed "safe_name" {
  expression = trimspace(lower(env("APP_NAME", "myapp")))
}
```

Use functions inside string interpolation:

```hcl theme={null}
task "deploy" {
  commands = [
    "docker push myapp:${substr(var.commit, 0, 8)}",
  ]
}
```
