If the loop index "i" isn't necessary, you can use simpler code:

import std.stdio: writeln;

void repeat(TF)(int n, lazy TF callme) {
    foreach (i; 0 .. n)
        callme();
}

void main() {
    repeat(5, writeln("hi"));
}

Bye,
bearophile

Reply via email to