# Initially empty list

**URL:** <https://cl.desmos.com/t/initially-empty-list/5211>\
**Category:** Questions\
**Created:** [November 1, 2023, 1:37am UTC](https://cl.desmos.com/t/initially-empty-list/5211 "2023-11-01T01:37:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Heller](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/steve_heller/32/3539_2.png) [@Steve\_Heller](https://cl.desmos.com/u/Steve_Heller)\
**Post date:** [November 1, 2023, 1:37am UTC](https://cl.desmos.com/t/initially-empty-list/5211/1 "2023-11-01T01:37:25Z")

</div>

B starts out empty, but in the full application, points would be added by actions later. C is a list of points. D is the combination of B & C through a 2-D list comprehension, but unfortunately, it breaks when B is empty. I expected the list comprehension to produce an empty list when any of its generators are empty.

![Screenshot 2023-10-31 at 9.34.22 PM](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/0/06474c367e3adc81fd9e2debd0dc32529b1ec0af.png)

But wait, there’s more. E is intended to be the first element of B combined with C, or an empty list when B is empty. I tried two ways, but no luck.

Adding any point, say (0,0), to B makes everything work. But I need it to work with B initially empty.

By the way, this all works if I replace points by scalars.

> **[Initially Empty Lists](https://www.desmos.com/calculator/cmbmekpiz9)**
>
> Explore math with our beautiful, free online graphing calculator. Graph functions, plot points, visualize algebraic equations, add sliders, animate graphs, and more.

---

<div class="post-metadata">

**Author:** ![pirsquared](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pirsquared](https://cl.desmos.com/u/pirsquared)\
**Post date:** [November 1, 2023, 5:24pm UTC](https://cl.desmos.com/t/initially-empty-list/5211/2 "2023-11-01T17:24:21Z")

</div>

I assume that Desmos thinks of lists as containing numbers by default, and only ‘knows’ it contains points once there’s a point in it. I guess the two best workarounds would be to either have B=[(0,0)] initially, and then make sure that your action replaces that value when it is fired first of all; or to have lists B\_x (empty), B\_y (empty), C\_x (all 1s), C\_y (1…5), which are combined into D as ((bx+cx,by+cy) for bx=B\_x, cx=C\_x, …)

---

<div class="post-metadata">

**Author:** ![Steve\_Heller](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/steve_heller/32/3539_2.png) [@Steve\_Heller](https://cl.desmos.com/u/Steve_Heller)\
**Post date:** [November 2, 2023, 11:46am UTC](https://cl.desmos.com/t/initially-empty-list/5211/3 "2023-11-02T11:46:36Z")

</div>

Yes, thanks. I had settled on the first, but finding an acceptable bonus point has been tricky and led to some bugs, so I was looking for a cleaner solution.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [November 6, 2023, 2:39pm UTC](https://cl.desmos.com/t/initially-empty-list/5211/4 "2023-11-06T14:39:54Z")

</div>

Alternate workaround, is to have an undefined point in your list:

```auto
B= [(1/0,0)]

```

You may just want your action to replace B using some sort of counter (instead of list length), so there’s only the new points added.

> **[Initially Empty Lists](https://www.desmos.com/calculator/x2l41py5ia)**
>
> Explore math with our beautiful, free online graphing calculator. Graph functions, plot points, visualize algebraic equations, add sliders, animate graphs, and more.

---

<div class="post-metadata">

**Author:** ![Steve\_Heller](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/steve_heller/32/3539_2.png) [@Steve\_Heller](https://cl.desmos.com/u/Steve_Heller)\
**Post date:** [November 6, 2023, 5:26pm UTC](https://cl.desmos.com/t/initially-empty-list/5211/5 "2023-11-06T17:26:52Z")

</div>

Thanks.

Yeah, I tried that. My bonus point was (Inf,inf), but compensating code is necessary. You compensated with a counter; I did it another way (adapting some interacting code in the real application: King’s Move).

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [November 6, 2023, 7:07pm UTC](https://cl.desmos.com/t/initially-empty-list/5211/6 "2023-11-06T19:07:04Z")

</div>

You could also have the initial point in list B and change your definition of b:

```auto
D= [b+c for b=B[2...max(2,length(B))],c=C ]

```

---

<div class="post-metadata">

**Author:** ![Steve\_Heller](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/steve_heller/32/3539_2.png) [@Steve\_Heller](https://cl.desmos.com/u/Steve_Heller)\
**Post date:** [November 7, 2023, 12:50am UTC](https://cl.desmos.com/t/initially-empty-list/5211/7 "2023-11-07T00:50:27Z")

</div>

In the actual code, B is used nine times.

At this point, I’m happy with the bonus point (inf,inf) and the one minor adjustment necessary.

Thanks again!
