# `Feel.Runtime.Partial`
[🔗](https://github.com/FeeJai/BDM/blob/feel-v0.1.0/apps/feel/lib/feel/runtime/partial.ex#L1)

The results of a `for` so far, for a body that only indexes `partial` (`partial[i - 1]`, `count(partial)`).

A body that reads `partial` as a list is given a list of the results, made again for each iteration: `m` cells for
the `m`th result, `m * m / 2` for a loop of `m`, and a read `partial[k]` is `k` steps in it (D-86, D-154). A body whose
every read is an index or a count (`Feel.Analysis.Iterations.view/2`) is given these results instead: an array that
the loop puts each result in, as it makes it, and that the reads look in. A result costs a few steps to put in, a
read costs a few steps whichever result it is of (the first, the last, the one in the middle), and the count is
the size. The array is a value that a result does not change (`:array` is functional), so the body keeps the one it
was given, as it kept its list.

The reads give what `Feel.Runtime.Filter.at/4` gives for the list of the results, for any index: the same value,
the same diagnostic and the same span. A newest-first list and its count would do for the reads of the last
results, and not for `partial[1]`, which is as far from the newest as the loop is long.

    iex> results = Enum.reduce([10, 20, 30], Feel.Runtime.Partial.new(), &Feel.Runtime.Partial.push(&2, &1))
    iex> Feel.Runtime.Partial.to_list(results)
    [10, 20, 30]
    iex> env = Feel.Runtime.Env.new()
    iex> {value, _env} = Feel.Runtime.Partial.at(env, results, Decimal.new(-1), {0, 10})
    iex> value
    30
    iex> {count, _env} = Feel.Runtime.Partial.count(env, results, {0, 14})
    iex> Decimal.to_integer(count)
    3

# `t`

```elixir
@opaque t()
```

# `at`

```elixir
@spec at(Feel.Runtime.Env.t(), t(), Feel.Value.t(), Feel.Diagnostic.span()) ::
  {Feel.Value.t(), Feel.Runtime.Env.t()}
```

`partial[index]`: the result at the index, as `Feel.Runtime.Filter.at/4` takes an element of the list of the results:
the first for `1`, the last for `-1`, and `null` for `0` and for a position that is not there; `null` with an error for
an index that is not a whole number, and for a value that is not a number.

# `count`

```elixir
@spec count(Feel.Runtime.Env.t(), t(), Feel.Diagnostic.span()) ::
  {Feel.Value.t(), Feel.Runtime.Env.t()}
```

`count(partial)`: the number of results, as `count` of the list of them gives it.

# `new`

```elixir
@spec new() :: t()
```

No results.

# `push`

```elixir
@spec push(t(), Feel.Value.t()) :: t()
```

The results with one more, after the others.

# `to_list`

```elixir
@spec to_list(t()) :: [Feel.Value.t()]
```

The results as a list, oldest first, which is what `partial` is for a body that reads it as a list.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
