8000 Array of indices lookup design · Issue #590 · PistonDevelopers/dyon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Array of indices lookup design #590
Closed
@bvssvni

Description

@bvssvni

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0