The OpenD Programming Language

withNeighboursSum

Lazy zip view of elements packed with sum of their neighbours.

  1. auto withNeighboursSum(Slice!(Iterator, N, kind) slice)
    template withNeighboursSum(alias fun = "a + b")
    static if(__traits(isSame, naryFun!fun, fun))
    withNeighboursSum
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) slice
    )
  2. auto withNeighboursSum(S[] slice)
  3. auto withNeighboursSum(S slice)

Members

Functions

withNeighboursSum
auto withNeighboursSum(Slice!(Iterator, N, kind) slice)
auto withNeighboursSum(S[] slice)
auto withNeighboursSum(S slice)

Parameters

fun

neighbours accumulation function.

Examples

import mir.ndslice.allocation: slice;
import mir.algorithm.iteration: all;

auto wn = [4, 5].iota.withNeighboursSum;
assert(wn.all!"a[0] == a[1] * 0.25");
assert(wn.map!"a" == wn.map!"b * 0.25");

See Also

Meta