The OpenD Programming Language

universal

Converts a slice to universal kind.

universal
(
Iterator
size_t N
SliceKind kind
Labels...
)
(
Slice!(Iterator, N, kind, Labels) slice
)

Parameters

slice Slice!(Iterator, N, kind, Labels)

a slice

Return Value

Type: auto

universal slice

Examples

auto slice = iota(2, 3).universal;
assert(slice == [[0, 1, 2], [3, 4, 5]]);
assert(slice._lengths == [2, 3]);
assert(slice._strides == [3, 1]);
import mir.ndslice.slice;
import mir.ndslice.allocation: slice;

auto dataframe = slice!(double, int, string)(2, 3);
dataframe.label[] = [1, 2];
dataframe.label!1[] = ["Label1", "Label2", "Label3"];

auto universaldf = dataframe.universal;
assert(universaldf._lengths == [2, 3]);
assert(universaldf._strides == [3, 1]);

assert(is(typeof(universaldf) ==
    Slice!(double*, 2, Universal, int*, string*)));
assert(universaldf.label!0[0] == 1);
assert(universaldf.label!1[1] == "Label2");

See Also

Meta