Closed
Description
Dyon supports array of indices lookup.
fn main() {
list := [[1, 2], [3, 4]]
x := [1, 0]
println(list[x]) // Prints `3`.
}
This can be used to easier work with N-dimensional arrays, discrete mathematics and group theory:
fn main() {
list := [[1, 2], [3, 4]]
// Transpose map.
x := [[[0, 0], [1, 0]], [[0, 1], [1, 1]]]
y := sift i, j {list[x[i][j]]}
println(list)
println(y)
// Prove that the transpose of transpose equals identity matrix.
x2 := sift i, j {x[x[i][j]]}
id := sift i 2, j 2 {clone([i, j])}
println(x2 == id) // Prints `true`.
}
It also makes secrets easier to use:
fn main() {
list := [[1, 2], [3, 5]]
list[where(max i, j {list[i][j]})] /= 2
println(list) // Prints `[[1, 2], [3, 2.5]]`.
}
This is designed for:
- Easier N-dimensional programming
- Easier use of secrets