Skip to content
Snippets Groups Projects
envelope.fut 801 B
Newer Older
let get_envelope_1d [n] (xs: [n]u8) (thickness: i64) : ([]u8, []u8) =
    let west = xs[0:thickness]
    let east = xs[n - thickness:]
    in (west, east)

let get_envelope_2d [n][m] (matrix: [n][m]u8) (thickness_y: i64) (thickness_x: i64): ([][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8) =
    let north = matrix[0:thickness_y]

    let north_west = matrix[0:thickness_y,0:thickness_x]
    let north_east = matrix[0:thickness_y,m - thickness_x:m]

    let south = matrix[n - thickness_y:]

    let south_east = matrix[n - thickness_y:n,m - thickness_x:m]
    let south_west = matrix[n - thickness_y:n,0:thickness_x]

    let east = matrix[:,m - (thickness_x):]
    let west = matrix[:,0:thickness_x]

    in (north, north_east, east, south_east, south, south_west, west, north_west)