# Updating a deeply nested array?

**URL:** <https://discourse.elm-lang.org/t/updating-a-deeply-nested-array/7928>\
**Category:** Learn\
**Created:** [November 21, 2021, 12:55pm UTC](https://discourse.elm-lang.org/t/updating-a-deeply-nested-array/7928 "2021-11-21T12:55:37Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![AvailableUsername](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@AvailableUsername](https://discourse.elm-lang.org/u/AvailableUsername)\
**Post date:** [November 22, 2021, 4:04pm UTC](https://discourse.elm-lang.org/t/updating-a-deeply-nested-array/7928/6 "2021-11-22T16:04:45Z")

</div>

I think the problem is that you have no way to represent variables in your syntax trees.  
You could add variables to your Expression type.

```
type Expression
    = Call CallExpression
    | Todo
    | NumberLiteral Float
    | Variable String

```

or, even, if you have a small number of possible variables (say, X and Y):

```
type Expression
    = Call CallExpression
    | Todo
    | NumberLiteral Float
    | X
    | Y

```

Then maintain a mapping of variables to values and use that mapping when doing computations with your trees.

In the first case (variables as strings):

```
type alias Mapping = Dict String Float

```

In the second case (just two variables X and Y):

```
type alias Mapping = { x: Float, y: Float}
```

---

_[View the full topic](https://discourse.elm-lang.org/t/updating-a-deeply-nested-array/7928)._
