-
Notifications
You must be signed in to change notification settings - Fork 36
Description
@9il
what do i use for toArray?
auto s=slice!double(3);
double[]s2= s.toArray;
actually not super clear from docs
Also, from old experimental.nslice in https://dlang.org/phobos/std_experimental_ndslice.html:
T median(Range, T)(Slice!(2, Range) sl, T[] buf)
{
import std.algorithm.sorting : topN;
// copy sl to the buffer
size_t n;
foreach (r; sl)
foreach (e; r)
buf[n++] = e;
buf[0 .. n].topN(n / 2);
return buf[n / 2];
}
this snippet (copy sl to the buffer) seems to indicate no such utility to flatten elements into an array?
EDIT: OK i guess it's here:
http://docs.algorithm.dlang.io/latest/mir_ndslice_allocation.html
-
somehow i find it hard to find, not sure if i'm the only one.
-
IMO this should be more prominent since we want to make it easy to go from standard D to slices (plenty of examples) as well as opposite direction (very sparse in docs)
-
not sure why
medianabove doesn't use ndarray -
the docs (
Creates a common n-dimensional array from a slice.) are not clear whether it allocates or merely returns a view over the data