On Wednesday, 21 August 2019 at 00:04:37 UTC, H. S. Teoh wrote:
On Tue, Aug 20, 2019 at 11:48:04PM +, ads via
Digitalmars-d-learn wrote: [...]
2) Deducing the string as you describe would require CTFE
(compile-time function evaluation), which usually isn't done
unless the resu
On Tuesday, 20 August 2019 at 23:48:04 UTC, ads wrote:
https://godbolt.org/z/hWENgc
A somewhat similar translation in C++ also creates a lot of
runtime instructions
https://godbolt.org/z/psyUtq
This piece of code creates a fizzbuzz string with template
parameters.
auto fizzbuzz(uint N)() {
string accumulate;
return fizzbuzz!N(accumulate);
}
auto fizzbuzz(uint N)(ref string result) if (N % 3 && N % 5) {
import std.conv : to;
result ~= N.to!string ~ "\n"
import std.stdio;
ubyte[] extend(in uint[] arr)
{
ubyte[] result;
foreach (n; arr)
{
if (n < 10)
{
result ~= n;
// source/app.d(10,11): Error: cannot
append type const(uint) to type ubyte[]