- Likes received
- 13,005
- Umbration
-
Caprice
I had to read this twice but I think I understand itExplanation time!
If I do this:
a = (0.5882,0.6705,0.8784,0.9686)
thena[0] == 0.5882
,a[1] == 0.6705
,a[2] == 0.8784
,a[3] == 0.9686
.
Of course, I don't have to create a name but can use the values directly:
(0.5882,0.6705,0.8784,0.9686)[0] == 0.5882
,(0.5882,0.6705,0.8784,0.9686)[1] == 0.6705
,(0.5882,0.6705,0.8784,0.9686)[2] == 0.8784
,(0.5882,0.6705,0.8784,0.9686)[3] == 0.9686
Instead of numbers, I can select withSD
:
(0.5882,0.6705,0.8784,0.9686)[SD-1]
So:
forSD == 1
:(0.5882,0.6705,0.8784,0.9686)[SD-1] == (0.5882,0.6705,0.8784,0.9686)[0] == 0.5882
,
forSD == 2
:(0.5882,0.6705,0.8784,0.9686)[SD-1] == (0.5882,0.6705,0.8784,0.9686)[1] == 0.6705
,
forSD == 3
:(0.5882,0.6705,0.8784,0.9686)[SD-1] == (0.5882,0.6705,0.8784,0.9686)[2] == 0.8784
,
forSD == 4
:(0.5882,0.6705,0.8784,0.9686)[SD-1] == (0.5882,0.6705,0.8784,0.9686)[3] == 0.9686
.
At this point we have already achieved selecting bySD
with the silent assumption thatSM == 1
The same way that we could get a value from a 1D array, we can get a 1D array from a 2D array:
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[0] == (0.5882,0.6705,0.8784,0.9686)
,
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[1] == (0.5490,0.6392,0.8666,0.9568)
,
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[2] == (0.4549,0.5647,0.8352,0.9450)
,
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[3] == (0.4313,0.5333,0.8235,0.9411)
.
But we can continue selecting from the already selected thing:
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[0][0] == (0.5882,0.6705,0.8784,0.9686)[0] == 0.5882
,
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[0][1] == (0.5882,0.6705,0.8784,0.9686)[1] == 0.6705
,
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[0][2] == (0.5882,0.6705,0.8784,0.9686)[2] == 0.8784
,
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[0][3] == (0.5882,0.6705,0.8784,0.9686)[3] == 0.9686
,
and so on.
And again, we can useSD
, andSM
for selecting:
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[SM-1][SD-1]
which is the final solution.
To see how it works, we can observe it for selected values.
Here I check it forSM == 2
andSD == 3
:
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[SM-1][SD-1]
becomes
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[2-1][3-1]
which is
((0.5882,0.6705,0.8784,0.9686),(0.5490,0.6392,0.8666,0.9568),(0.4549,0.5647,0.8352,0.9450),(0.4313,0.5333,0.8235,0.9411))[1][2]
which is
(0.5490,0.6392,0.8666,0.9568)[2]
which is
0.8666
and similarly it will work for other values.

I've never worked with arrays much in programming so I had to expand my brain a bit but I think it fits now


Thank you very much