# Condensing the code

correct= when figure1number = 2 or figure1number =3 “Correct” otherwise “Not there yet, keep working”

Take that code from above, is there a way to write it as just:

correct = when figure1number = (2 or 3)

instead of having to write “when figure1number” each time?

It would be nice. Where does figure1number come from?

here is the whole code, i shortened figure1number to just fn1:

t=table1

fn1 = t.cellNumericValue(1,1)
fn2 = t.cellNumericValue(2,1)
fn3 = t.cellNumericValue(3,1)
fn4 = t.cellNumericValue(4,1)
fn5 = t.cellNumericValue(5,1)

r = randomGenerator()

a = r.int(-10,10)
b = r.int(-10,10)
c = r.int(-10,10)
d = r.int(-10,10)
e = r.int(-10,10)

a2 = r.int(-10,10)
b2 = r.int(-10,10)
c2 = r.int(-10,10)
d2 = r.int(-10,10)
e2 = r.int(-10,10)

correct=
`when (fn1 = a or fn1 =b or fn1 =c or fn1 =d or fn1 =e) and not(fn1 = fn2) and not(fn1 = fn3) and not(fn1 = fn4) and not(fn1 = fn5) `

`and (fn2 = a or fn2 =b or fn2 =c or fn2 =d or fn2 =e) and not(fn1 = fn2) and not(fn2 = fn3) and not(fn2 = fn4) and not(fn2 = fn5) `

` and (fn3 = a or fn3 =b or fn3 =c or fn3 =d or fn3 =e) and not(fn1 = fn3) and not(fn2 = fn3) and not(fn3 = fn4) and not(fn3 = fn5)`

`and (fn4 = a or fn4 =b or fn4 =c or fn4 =d or fn4 =e) and not(fn1 = fn4) and not(fn4 = fn3) and not(fn3 = fn4) and not(fn4 = fn5)`

` and (fn5 = a or fn5 =b or fn5 =c or fn5 =d or fn5 =e) and not(fn1 = fn5) and not(fn5 = fn3) and not(fn3 = fn5) and not(fn4 = fn5)`

``````     "Correct" otherwise "Not there yet, keep working"
``````

content: "Write the domain values in the table below for the following set of coordinate:

`{(\${a},\${a2}) (\${b},\${b2}) (\${c},\${c2}) (\${d},\${d2}) (\${e},\${e2})}`

Hit enter to add more lines on the table if needed

so essentially the note creates random coordinates, and the students have to take the domain values and list them in the table. The reason I asked that other question about avoiding duplicate numbers when randomly generating, was because of this code. I have fn1 set up to be any of the possible values, but not equal to any of the other fn variables, but if one other the other fn variables is the same, then I have a problem.

Gotcha. Related to the other post. I’d try the list thing. I’ve got this graph I made a bunch for a bunch of list functions. Some might be unnecessary with new list methods, but again I don’t know what they are yet or if they’re just in CL.

https://www.desmos.com/calculator/avs3mnjpik

1 Like

I’m not even sure that works, because it’s possible to get repeated values in your numbers.

As Daneil said, your best bet would be to get those numbers into a list and use the new list functionality.

Here’s a way to use it to get all the unique values in a list. You can expand that to get the differences between two lists, and your correct will happen when all the differences are zero.

https://www.desmos.com/calculator/bkzf0bpvqz

Maybe like this?

I’m going to look more into it, but from first glance this seems to perfectly do what I was needing!

Your abilities are far beyond mine, so I cant fully comprehend the code, but I was able to mess with it some. Overall it was exactly what I needed. I was able to mess with it some to apply it to finding domain and range from a table as well. Wanted to show you what I did with it. The tables are the last two slides on this desmos. I really appreciate the help!

2 Likes

No worries. All of the real work is in the graph, including both generating the data points, and the check for correctness.

I did it that way because the list math doesn’t seem to work too good in CL.

1 Like