The OpenD Programming Language

rcarray

Examples

RCArray!double a = rcarray!double(1.0, 2, 5, 3);
assert(a[0] == 1);
assert(a[$ - 1] == 3);

auto s = rcarray!char("hello!");
assert(s[0] == 'h');
assert(s[$ - 1] == '!');

alias rcstring = rcarray!(immutable char);
auto r = rcstring("string");
assert(r[0] == 's');
assert(r[$ - 1] == 'g');

With Input Ranges

import mir.algorithm.iteration: filter;
static immutable numbers = [3, 2, 5, 2, 3, 7, 3];
static immutable filtered = [5.0, 7];
auto result = numbers.filter!"a > 3".rcarray!(immutable double);
static assert(is(typeof(result) == RCArray!(immutable double)));
assert (result[] == filtered);

Meta