---
title: Types of brackets
description: What spaces, `;`, `◇` and line breaks mean inside brackets, parentheses
  and braces
---
BPL has three kinds of bracket: brackets `[ ]`, parentheses `( )` and braces `{ }`. The separators space, `;` and [`◇`](https://bpl.fast.ai//glyphs/diamond.html) have different meanings in each kind of bracket. A line break means [`◇`](https://bpl.fast.ai//glyphs/diamond.html), except just inside a bracket or next to `;`, [`◇`](https://bpl.fast.ai//glyphs/diamond.html) or [`?`](https://bpl.fast.ai//glyphs/question.html), where it separates nothing. For what brackets and braces create, see [Arrays](arrays.md) and [Dfns](dfns.md).

| Inside | Space | `;` | [`◇`](https://bpl.fast.ai//glyphs/diamond.html) or a line break |
|--- |--- |--- |--- |
| `[ ]` | Separates items | Separates items that contain spaces | Separates rows of an array |
| `( )` | Separates runs | Not allowed | Separates rows of a vector |
| `{ }` | Separates runs | Separates bodies | Separates statements |
| Top level | Separates runs | Not allowed | Separates statements |

A [run](terms.md#term-run) is a sequence of tokens with no spaces between them. [Syntax](syntax.md#runs) gives the rules for runs.

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Brackets

Brackets are used to write vectors. Inside brackets, spaces separate items:

```bpl
a←1
b←2
[a b]
```

```output
1 2
```

An item can be any expression without spaces:

```bpl
[a+b a×b]
```

```output
3 2
```

An item can use a name that an earlier item assigns, because items are evaluated left to right:

```bpl
[c←1 ≥c]
```

```output
1 2
```

To keep an expression containing spaces as one bracket item, put it in parentheses.

```bpl
x←2 4 9
[(+/x ÷ ≢x) ≢x]
```

```output
5 3ₓ
```

When several items need spaces, separate them with `;` and write each item as you would outside brackets:

```bpl
[+/x ; +/x ÷ ≢x]
```

```output
15 5
```

A `;` list can run over several lines, because a line break after `;` separates nothing:

```bpl
[+/x ;
 +/x ÷ ≢x]
```

```output
15 5
```

With [`◇`](https://bpl.fast.ai//glyphs/diamond.html) or a line break, a bracket list is an array whose major cells are the rows:

```bpl
m←[1 2 3
   4 5 6]
m
```

```output
1 2 3
4 5 6
```

Rows of different lengths are padded with fill:

```bpl
[1 2◇3 4 5]
```

```output
1 2 0
3 4 5
```

You can't use both `;` and [`◇`](https://bpl.fast.ai//glyphs/diamond.html) inside the same pair of brackets.

Brackets are not used for indexing. To select from an array, use [Index](glyphs/squad.md) [`⌷`](https://bpl.fast.ai//glyphs/squad.html), or a [subscript](scripts.md#subscripts) for one position.

## Parentheses

Parentheses group one expression, read as it would be at the top level:

```bpl
(2×3)+4
```

```output
10
```

With [`◇`](https://bpl.fast.ai//glyphs/diamond.html), a parenthesised list is a vector of rows, which can have different lengths. A row with one item is still a vector:

```bpl
rows←(4◇4 5)
rows
ρ¨rows
```

```output
(4◇4 5)
(1◇2)ₓ
```

Inside parentheses, a line break starts a new row, as [`◇`](https://bpl.fast.ai//glyphs/diamond.html) does, rather than continuing the expression:

```bpl
("ab"
 "cd")
```

```output
("ab"◇"cd")
```

In brackets, the same rows form one array, padded with fill:

```bpl
[4◇4 5]
```

```output
4 0
4 5
```

## Braces

Braces define a function, whose statements are separated by [`◇`](https://bpl.fast.ai//glyphs/diamond.html) or line breaks:

```bpl
{x←ω
 ≥x}2
```

```output
3
```

When a body's predicate `C?` is false, evaluation moves on to the next body after `;`:

```bpl
{ω<0?-ω;ω}¯3
```

```output
3
```

## The top level

Outside any bracket, [`◇`](https://bpl.fast.ai//glyphs/diamond.html) and line breaks separate statements. A `;` at the top level raises a `SYNTAX` error.
