# Dynamical matrix growth

**URL:** <https://community.wolfram.com/t/dynamical-matrix-growth/4569>\
**Category:** Questions\
**Tags:** mathematica, interface-construction\
**Created:** [January 20, 2015, 8:25am UTC](https://community.wolfram.com/t/dynamical-matrix-growth/4569 "2015-01-20T08:25:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![boristhphys](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/boristhphys/32/3064_2.png) [@boristhphys](https://community.wolfram.com/u/boristhphys)\
**Post date:** [January 20, 2015, 8:25am UTC](https://community.wolfram.com/t/dynamical-matrix-growth/4569/1 "2015-01-20T08:25:13Z")

</div>

I am trying to create a list that grows as new elements are entered one by one in the InputField. Tried this code:

```
InputField[Dynamic[ss]]
T = {};

Dynamic[AppendTo[T, ss], ContinuousAction -> False]

```

But ended up in infinite loop. Any ideas?

Thanks.

---

<div class="post-metadata">

**Author:** ![nma](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@nma](https://community.wolfram.com/u/nma)\
**Post date:** [January 20, 2015, 11:36am UTC](https://community.wolfram.com/t/dynamical-matrix-growth/4569/2 "2015-01-20T11:36:10Z")

</div>

how about

```
T = {};
ss = Null;
Grid[{{InputField[Dynamic[ss, {ss = #; AppendTo[T, ss] } &]]}, {Dynamic[T]}}, Frame -> All]

```

![4024movie.gif](https://global.discourse-cdn.com/wolfram/original/3X/0/a/0af4322d49e5a82d482aa4c2bfa8aa739335a821.gif)

---

<div class="post-metadata">

**Author:** ![boristhphys](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/boristhphys/32/3064_2.png) [@boristhphys](https://community.wolfram.com/u/boristhphys)\
**Post date:** [January 20, 2015, 8:01pm UTC](https://community.wolfram.com/t/dynamical-matrix-growth/4569/3 "2015-01-20T20:01:24Z")

</div>

Thanks, Nasser.

Why doesn’t `rr` being updated here? It just returns `rr`:

```
dd = Null; 
InputField[Dynamic[rr, {(dd = #) & }]]

Dynamic[dd]
Dynamic[rr]

```

---

<div class="post-metadata">

**Author:** ![nma](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@nma](https://community.wolfram.com/u/nma)\
**Post date:** [January 21, 2015, 11:09am UTC](https://community.wolfram.com/t/dynamical-matrix-growth/4569/4 "2015-01-21T11:09:56Z")

</div>

> InputField[Dynamic[rr, {(dd = #) & }]]

You can’t do the above. The symbol to the left of `=` has to the dynamic symbol in the first argument to dynamics which is `rr`.

When using the second argument of dynamics, you are overriding the default behavior of Dynamics, which is to assign to `rr` (the thing in the first argument) the current slider value as it is being changed. Therefore, you have now to do this yourself, by writing `rr=#&`, else `rr` will never get updated. You are now in control of Dynamics. Since you did not update `rr` in the second argument, it never got assigned to the input.

The second argument of dynamics can be single pure function (as in this example), or it can be a list of two pure functions. In this case, the first function is used during interaction, and the second is evaluated at end of interaction.

Or it can be a list of 3 pure functions, in this case, the first function is evaluated at start of interaction, and the second is evaluated during interaction, and the third is evaluated at end of the interaction (when you release the mouse). This way, you can have complete control of Dynamics at each phase.

---

<div class="post-metadata">

**Author:** ![boristhphys](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/boristhphys/32/3064_2.png) [@boristhphys](https://community.wolfram.com/u/boristhphys)\
**Post date:** [January 21, 2015, 2:13pm UTC](https://community.wolfram.com/t/dynamical-matrix-growth/4569/5 "2015-01-21T14:13:21Z")

</div>

Thanks.
