Introduction to programming with compile time sequences in D
Petar
Petar
Tue Aug 25 14:02:33 UTC 2020
On Tuesday, 25 August 2020 at 02:11:42 UTC, data pulverizer wrote:
> I have a draft new blog article "Introduction to programming
> with compile time sequences in D", it's on Github and I would
> appreciate feedback before it goes live
> https://gist.github.com/dataPulverizer/67193772c52e7bd0a16414cb01ae4250
>
> Comment welcome.
>
> Many thanks
Nice article! I haven't had the chance to read it fully, so far
now I have just one quick suggestion regarding removing items
from sequences [0]. I think it would be much simpler (and likely
more efficient) to avoid both recursion and static foreach and
simply use slicing + concatenation. Here's an example:
template removeFromSeqAt(size_t idx, seq...)
{
static if (seq.length > 0 && idx < seq.length)
alias removeFromSeqAt = AliasSeq!(seq[0 .. idx], seq[idx + 1
.. $]);
else
static assert (0);
}
You can find a full example of this here:
https://run.dlang.io/gist/run-dlang/80e120e989a6b0f72fd7244b17021e2f
[0]:
https://gist.github.com/dataPulverizer/67193772c52e7bd0a16414cb01ae4250#removing-items-from-a-compile-time-sequence
More information about the Digitalmars-d-announce
mailing list