Setting a counter variable to keep track of something

Dear All,

In my activity, I would like to check how many times consecutively a variable called user_input is over 10. So, I would like to create a counter variable i to keep track of it.

I would like to set 1 to i if the user enters \left| user_input \right| >10 for the first time, and then add 1 to i if the user enters another \left| user_input \right| >10 again consecutively but reset i to 0 if the next value of \left| user_input \right| is less then 10.

I get stuck because CL does not have the += operator like other languages. Is there a way to get around it?

I am new to CL so I would like to beg your pardon in advance if the answer is obvious.

The answer isn’t obvious.

I think this will do what you want:

CL doesn’t handle number lists very well, so I created a hidden graph to deal with them.
The graph takes a number list, and creates variables for its total, and the negative of the total.
I then us CL to assign the history of a value associated with button presses to that number list.
Finally, the history I keep is either a one if the answer is correct, or the negative total if it’s worn (thereby cancelling all of the previous values)

Display the total from the graph as your current running correct count.

1 Like

Thank you so much Friedrich! This is exactly what I want. I did not know the graph calculator in Desmos had the list.length,, and {conditional: do if true, do if false} functions. I think I will use them extensively from now on.