do { \
switch(d) { \
case 0: \
fprintf(out, "%lu\n", id); \
break; \
case 1: \
fprintf(out, "%lu "f"\n", id, tup[0]); \
break; \
case 2: \
fprintf(out, "%lu "f" "f"\n", id, tup[0], tup[1]); \
break; \
case 3: \
fprintf(out, "%lu "f" "f" "f"\n", id, tup[0], tup[1], tup[2]); \
break; \
case 4: \
fprintf(out, "%lu "f" "f" "f" "f"\n", id, tup[0], tup[1], tup[2], tup[3]); \
break; \
default: \
\
fprintf(out, "%lu "f" "f" "f" "f" "f, id, \
tup[0], tup[1], tup[2], tup[3], tup[4]); \
\
for(size_t j = 4; j < d; ++j) { \
fprintf(out, " "f, tup[j]); \
} \
fputs("\n", out); \
} \
} while(0)
Print a tuple of a few items. fprintf is much faster if you can call it with everything you need; here, we have code for 0..4 items, and we write out the loop if we need more. We could unroll the loop a bit more, but that's more trouble than it's currently worth since I only ever print 4-tuples (3-simplices).