Issue has nothing to do with recursion. That's only where I keep seeing it.

eg a function to generate combinations.

import std.stdio;

int[3] t;

void foo (int i) {
  if (i == 3)
    writef("%s\n", t);
  else foreach (x; 0 .. 3) {
    t[i] = x;
    foo(i+1);
  }
}

void main() {
  foo(0);
}

In C, I could put in the equivalent for statement for foreach, t[i] as the iterating variable. I won't need x which exists as a middleman only and save myself two lines.

Reply via email to