Search Results
7/19/2025, 9:42:59 PM
>>105958521
>I don't understand how adding and muliplying the integers to get one value each time produces indices corresponding to either array. I thought with the earlier examples, like getting diagonals, that the lambda procedure was returning index coordinates as values through list mapping or recursion (ie (0 0) for a, (1 1) for e, (2 2) for i):
I think you're right on that. It may help to think of the arrays as functions, say you had two arrays a and b:
a = [a, b, c, d]
b = [[a, b],
[c, d]]
They could be written as functions:
a(0) = a
a(1) = b
a(2) = c
a(3) = d
b(0, 0) = a
b(1, 0) = b
b(0, 1) = c
b(1, 1) = d
You could write b in terms of a like:
b(x, y) = a(x + y * 2)
b(0, 0) = a(0)
b(1, 0) = a(1)
b(0, 1) = a(2)
b(1, 1) = a(3)
As a shorthand maybe you could define b as b = f(a, (x + y * 2), (1, 1)), where f is a function that generates each of b's 4 cases up to the bounds (1, 1). f would have the same meaning as make-shared-array
Why does the body of b, (x + y * 2), have to use whole number integers like 2? If it didn't and b computed 1.5, our function a isn't defined for a(1.5)
>I don't understand how adding and muliplying the integers to get one value each time produces indices corresponding to either array. I thought with the earlier examples, like getting diagonals, that the lambda procedure was returning index coordinates as values through list mapping or recursion (ie (0 0) for a, (1 1) for e, (2 2) for i):
I think you're right on that. It may help to think of the arrays as functions, say you had two arrays a and b:
a = [a, b, c, d]
b = [[a, b],
[c, d]]
They could be written as functions:
a(0) = a
a(1) = b
a(2) = c
a(3) = d
b(0, 0) = a
b(1, 0) = b
b(0, 1) = c
b(1, 1) = d
You could write b in terms of a like:
b(x, y) = a(x + y * 2)
b(0, 0) = a(0)
b(1, 0) = a(1)
b(0, 1) = a(2)
b(1, 1) = a(3)
As a shorthand maybe you could define b as b = f(a, (x + y * 2), (1, 1)), where f is a function that generates each of b's 4 cases up to the bounds (1, 1). f would have the same meaning as make-shared-array
Why does the body of b, (x + y * 2), have to use whole number integers like 2? If it didn't and b computed 1.5, our function a isn't defined for a(1.5)
Page 1