Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of indices lookup design #590

Closed
bvssvni opened this issue Mar 1, 2019 · 0 comments
Closed

Array of indices lookup design #590

bvssvni opened this issue Mar 1, 2019 · 0 comments

Comments

@bvssvni
Copy link
Member

bvssvni commented Mar 1, 2019

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant