Here's the code that doesn't compile:
import std.stdio, std.experimental.ndslice, std.range,
std.algorithm;
void main()
{
auto alloslice = [1, 2, 3, 4].sliced(1,4);
auto sandwich = chain(alloslice,
(0).repeat(8).sliced(2,4),
alloslice);
writeln(sandwich);
}
If I comment out the line with the repeat, or allocate the repeat
with .array(), everything is fine. I get that the types are
incompatible in some way, but it seems like I should be able to
lazily instantiate those zeros whenever I need to (later). Should
this work? Is there a different way to set up all of the ranges
without allocating everything up front?
And yeah, resources aren't particularly limited for my
application, so allocating everything wouldn't hurt, but I'm
trying to really understand all of these little details about
ranges. I love them when they work, but the learning curve has
been steep.