Elementwise Arithmetic vox.lit

Various utilities for elementwise operations on arrays; allows more concise expression of elementwise equality, comparison, and arithmetic. These functions are available in the local scope in the Add/Remove Voxels and PowerEdit tools.

Examples:

a = [1, 2, 3, 4]
b = [1, 2, 3, 4]
equal a, b # true

c = [4, 5, 6, 7]
d = [2, 3, 4, 5]
sub c, d # [2, 2, 2, 2]

Methods

Call methods with.name(),.name(arguments)or just .name arguments .

  • add (a, b) -> Array#

    Elementwise adds a and b. If the arrays are different lengths, an array of the shorter length is returned.

    Parameters
    a
    Array
    b
    Array
    Return
    return
    Array
  • all (a) -> Boolean#

    Returns true if all elements of a evaluate to true

    Parameters
    a
    Array
    Return
    return
    Boolean
  • any (a) -> Boolean#

    Returns true if any elements of a evaluate to true

    Parameters
    a
    Array
    Return
    return
    Boolean
  • cmp (a, b) -> -1/0/1#

    Performs lexicographic, elementwise comparison on a and b; if a is the "larger" array, returns 1; if b is larger, returns -1; else returns 0.

    Arrays are first compared based on length (longer is larger), then each element is compared in sequence (a[0] vs b[0], then a[1] vs. b[1], and so on).

    Parameters
    a
    Array
    b
    Array
    Return
    return
    -1/0/1

    1 if a is greater, -1 if b is greater, 0 if equal

  • div (a, b) -> Array#

    Elementwise divides a and b. If the arrays are different lengths, an array of the shorter length is returned.

    Parameters
    a
    Array
    b
    Array
    Return
    return
    Array
  • greater (a, b) -> Boolean#

    Returns true if a is elementwise greater than b, else false

    Parameters
    a
    Array
    b
    Array
    Return
    return
    Boolean
  • greaterEq (a, b) -> Boolean#

    Returns true if a is elementwise greater than or equal to b, else false

    Parameters
    a
    Array
    b
    Array
    Return
    return
    Boolean
  • less (a, b) -> Boolean#

    Returns true if a is elementwise less than b, else false

    Parameters
    a
    Array
    b
    Array
    Return
    return
    Boolean
  • lessEq (a, b) -> Boolean#

    Returns true if a is elementwise less than or equal to b, else false

    Parameters
    a
    Array
    b
    Array
    Return
    return
    Boolean
  • mul (a, b) -> Array#

    Elementwise multiplies a and b. If the arrays are different lengths, an array of the shorter length is returned.

    Parameters
    a
    Array
    b
    Array
    Return
    return
    Array
  • sub (a, b) -> Array#

    Elementwise subtracts a and b. If the arrays are different lengths, an array of the shorter length is returned.

    Parameters
    a
    Array
    b
    Array
    Return
    return
    Array
  • sum (a) -> Number#

    Returns the sum of the elements in a

    Parameters
    a
    Array
    Return
    return
    Number

    Sum of elements in a