Appending static arrays
Nordlöw via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 17 11:48:10 PDT 2017
On Monday, 17 July 2017 at 17:38:23 UTC, Nordlöw wrote:
> I'm want to define a specialization of `append()` that takes
> only static arrays as inputs and returns a static array being
> the sum of the lengths of the inputs.
>
> Have anybody already implemented this?
>
> If not, I'm specifically interested in how to most conveniently
> infer the length (as an enum) of the returned static array from
> the `.length`s of inputs (which of course must be enum-values
> too).
I just realized that I can use `std.meta.staticMap` to get the
lengths but I still need to reduce them and there is no variant
of `reduce` in `std.meta`. Why? Hasn't it been written yet?
I know I can always write yet another recursive CT-function, say
`SumOfLengths`, but I thought I'd try to reuse `std.meta` this
time. :)
More information about the Digitalmars-d-learn
mailing list