• map two arrays to a "field" of 2D array through a mapping function.
    given a mapping function map_fn, and two arrays x_values and y_values, this function generates a 2D array where each element is the result of applying map_fn to the corresponding elements from x_values and y_values.

    Type Parameters

    • X
    • Y
    • Z

    Parameters

    • map_fn: ((x, y) => Z)

      the mapping function that takes an x value from x_values and a y value from y_values, and returns the mapped z_value

        • (x, y): Z
        • Parameters

          Returns Z

    • x_values: X[]

      the values to be used as the major axis (rows) of the resulting 2D array

    • y_values: Y[]

      the values to be used as the minor axis (columns) of the resulting 2D array

    Returns Array2D<Z>

    a 2D array with mapped values from x_values and y_values

    Example

    z is a function of x and y defined by: z(x, y) = x + y.
    to create a 2d grid of z_values using x_values = [1, 2, 3] and y_values = [4, 5], we do the following:

    const
    add = (x: number, y: number) => (x + y),
    x_values = [1, 2, 3],
    y_values = [4, 5],
    z_values = meshMap(add, x_values, y_values)
    z_values === [
    [5, 6],
    [6, 7],
    [7, 8],
    ]

Generated using TypeDoc