# Empty number list rather than undefined for history?

**URL:** <https://cl.desmos.com/t/empty-number-list-rather-than-undefined-for-history/1604>\
**Category:** Questions\
**Created:** [October 1, 2020, 1:30am UTC](https://cl.desmos.com/t/empty-number-list-rather-than-undefined-for-history/1604 "2020-10-01T01:30:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FRIEDRICH\_KNAUSS](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/friedrich_knauss/32/528_2.png) [@FRIEDRICH\_KNAUSS](https://cl.desmos.com/u/FRIEDRICH_KNAUSS)\
**Post date:** [October 1, 2020, 1:30am UTC](https://cl.desmos.com/t/empty-number-list-rather-than-undefined-for-history/1604/1 "2020-10-01T01:30:11Z")

</div>

This isn’t quite a bug, but it is an akwardness.

I want to be able to track a variable to fake a reset every other time a button is pushed. That part is easy, ish.

What’s tough is how to deal with it at the very beginning. Before the button is pressed, the number list is undefined, and getting the calculator to deal nicely with undefined values is a bear, and because it’s a number list there’s no polite way to create a dummy in CL to pass in until it is defined.

Would it break too many things if instead of undefined, the history for an unpressed button was a 0 element list?

---

<div class="post-metadata">

**Author:** ![HumanizedMath](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/humanizedmath/32/2947_2.png) [@HumanizedMath](https://cl.desmos.com/u/HumanizedMath)\
**Post date:** [October 1, 2020, 12:45pm UTC](https://cl.desmos.com/t/empty-number-list-rather-than-undefined-for-history/1604/2 "2020-10-01T12:45:48Z")

</div>

I usually just use something to the effect of:

```auto
when button.presscount=0 0 otherwise ___

```

To account for the single case before the button history is populated.

As for buttons setting and resetting, I tend to define a variable using the mod function depending on how many presses needed usually mod(p,2) or mod(p,3) where p is the number of button presses

---

<div class="post-metadata">

**Author:** ![FRIEDRICH\_KNAUSS](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/friedrich_knauss/32/528_2.png) [@FRIEDRICH\_KNAUSS](https://cl.desmos.com/u/FRIEDRICH_KNAUSS)\
**Post date:** [October 1, 2020, 4:35pm UTC](https://cl.desmos.com/t/empty-number-list-rather-than-undefined-for-history/1604/3 "2020-10-01T16:35:11Z")

</div>

That works for numbers. If you’re using history, though, it expects a number list and there’s no way to make CL create an empty number list.

I tried creating an empty list in the graph that I could access and pass in instead, but it balked at that as well.

---

<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:** [October 1, 2020, 4:51pm UTC](https://cl.desmos.com/t/empty-number-list-rather-than-undefined-for-history/1604/4 "2020-10-01T16:51:14Z")

</div>

There’s a length command now. What about

`when button.history("X").length >0 ...`

---

<div class="post-metadata">

**Author:** ![HumanizedMath](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/humanizedmath/32/2947_2.png) [@HumanizedMath](https://cl.desmos.com/u/HumanizedMath)\
**Post date:** [October 1, 2020, 5:16pm UTC](https://cl.desmos.com/t/empty-number-list-rather-than-undefined-for-history/1604/5 "2020-10-01T17:16:14Z")

</div>

If you have a particular example, I could take a look. I have done a work around for this many times because I’ve created infinite problem generators. So I usually have to deal with the case before the button is ever pressed.
