Hello! I’m working on a graph that is supposed to emulate a pixel screen (here: Computer? | Desmos ) I found a way to flatten a list and convert from x,y positions to screen positions, but I am having trouble replacing values. I know you can use R_{eplace}\left(L,i,v\right)=\left[\left\{\operatorname{total}\left(\left\{j=i:1,0\right\}\right)>0:v,L\left[j\right]\right\}\operatorname{for}j=\left[1...\operatorname{length}\left(L\right)\right]\right] to replace a value in a list, and I was able to modify it to take multiple indexes, but not multiple values. (I kept getting the ‘list in list’ error) Line 20 in the graph is where I have my most recent attempt at solving it, and I want to be able to do something like this:C_{hange}\left(\left(X,Y,C\right)\right) where X and Y are lists of the screen coordinates and C is a list of the colors to change them to. I have to thank all of you for being so much help!
For R_{esetScreen}, are you just trying to change P_{ixelList} to the list (i,j,1)? If so, I think you can do it more explicitly instead of using your function.
R_{esetScreen}=P_{ixelList}\to\left[\left(i,j,1\right)\operatorname{for}i=\left[1...S_{creenWidth}S_{creenResolution0}-1\right],j=\left[0...S_{creenHeight}S_{creenResolution0}\right]\right]
I’m actually trying to make the entire list just 1s, and yes, I could do something on the line of repeat(1, length(S_{creen}), but I wanted to use my fancy function. I think I forgot to mention it in the original post, but where I want to use it is in line 109, (the P_{layer}\left(d_t\right) function) where I use it to input the player’s position and have it show a pixel on screen.
I can make it change only 1 pixel at a time (Here’s what it looks like: Computer? | Desmos ) but anything more and it doesn’t like it.
I’m having a little trouble wrapping my head around it, but your note that it is doing the full list instead of length(PosColor) is because your R_eplace function is dependent on the length of your list argument, which is P_ixelList, not PosColor. I think maybe updating C_hange with this added to the end, if I’m understanding correctly.
[1...length(P_{osColor})].join(P_{ixelList})[length(P_{osColor})+1...length(P_{ixelList})])
I’m basically trying to do this: Replacing multiple elements in a list at once , but be able to make the points different colors based on what I input. Line 8 in here is pretty close to what I have Replace items in list. | Desmos .
I think this is what you are looking for:
https://www.desmos.com/calculator/fhyjtppaag
What is making you crazy is the function
indexOf(v,L)= [1...length(L)] [L=v]
because you have to be careful that it does return a list (even if it only contains one element) …
if you only want the first index you need to use
indexOf(v,L)= [1...length(L)] [L=v][1]
I see… You’re using the P_{pos} function to replace the values of j with undefined, except for the values of I, and using that to get the right indexes. Very clean. Thank you! This helps a lot.
It now works:
Yep, thank you again! (I forgot that you had to click the solution button for a minute there
)
no problem, glad to help, and nice job with your idea …
I had the same issue debugging something yesterday! “Why is this saying it’s a list when I’m seeing a single point as ouput in this line?”
Yes, the output should be sometyhing like [1] instead of simply 1 … to show that it is a list … but it seems to me that under certain circumstances the square brakets are not there or one is not able to see them.
I realize that’s an issue. I think I’ll pass that to the team. It feels pretty useful to be aware of if you’re trying to debug things.