# Buckets

## Type Declaration

```
Specific Bucket Name: {*Context Type*}.
```

## Operators

### Accessing

#### Containment

```
some bucket: {*Context Type*} [context a, context b];

`Index checks.`
some bucket(1?) = true
some bucket(2?) = false

`ID checks.`
some bucket(context a id?) = true
some bucket(context c id?) = false
```

```
some bucket: {*Context Type*} [context a, context b];
some bucket(1?, context c id?) = {true, false}
```

#### Retrieving

```
some bucket: {*Context Type*} [context a, context b];
some bucket(0) = {*context a*}
some bucket(context b id) = {*context b*}
```

```
some bucket: {*Context Type*} [context a, context b];
some bucket(...) = {*context a, context b*}  `Total collection accessor.`
```

### Difference (Remove Elements)

```
{*context a, context b*} - {*context b, context c*} = {*context a*}
```

### Filter

```
`Filter for a Behavior.`
`Generic 'T' is treated as the defined type, Base Context.`

Manage {*T*} (T [Base Context]): {contexts},
    where contexts filtered by [(a) => a meets criteria]?
    
    `Behavior Operations.`
```

```
`Filter for an Operation.`
Update {*Context Type*}: <contexts>,
    where positive contexts is contexts filtered by [(a) => a(Value A) > 0],
    where negative contexts is contexts filtered by [(a) => a(Value A) < 0],
    when |positive contexts| > 0 and |negative contexts| > 0?
    
    `Operation Logic.`
```

### Intersection

```
{*context a, context b*} % {*context b, context c*} = {*context b*}
```

### Sort

```
`Sort for a Behavior.`
`Generic 'T' is treated as the defined type, Base Context.`

Manage {*T*} (T [Base Context]): {contexts},
    where contexts sorted by [(a, b => a - b]?
    
    `Behavior Operations.`
```

```
`Sort for an Operation.`
Update {*Context Type*}: <contexts>,
    where ordered contexts is contexts sorted by [(a, b) => a - b],
    where reversed contexts is contexts sorted by [(a, b) => b - a]?
    
    `Operation Logic.`
```

### Union (Appending)

```
{*context a, context b*} + {*context b, context c*} = 
    {*context a, context b, context c*}
```

## As Variables

### Assignment

```
some bucket is {*context a, context b*},
```

```
some operable is {*context a, context b*} + {*context b, context c*},
```

### Declaration

```
some bucket: {*Context Type*} [context a, context b];
```

```
specific bucket: Specific Bucket Name [context a, context b];
```

```
some bucket: {*Context Type*} [{*context a, context b*} + {*context b, context c*}];
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rede.gitbook.io/rede-language-design/annexes/annex-c/data-types/built-in-types/context-collections/buckets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
