Empty number list rather than undefined for history?

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?

I usually just use something to the effect of:

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

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.

There’s a length command now. What about

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

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.