import std.stdio;
void seq_apply(uint ArgNum, Func, Args...)(Func func, Args args) {
func(args[0], args[1 .. ArgNum + 1]);
static if (args.length > ArgNum + 1) {
seq_apply!(ArgNum)(func, args[ArgNum + 1 .. args.length]);
}
}
class obj {
void setxxx(int x) {
writefln("setxxx: %d", x);
}
void setyyy(int y) {
writefln("setyyy: %d", y);
}
}
void f(obj x, int a0, int a1) {
x.setxxx(a0); x.setyyy(a1);
}
void main(string[] argv) {
obj x1 = new obj(), x2 = new obj();
seq_apply!(2u)(&f,
x1, 1, -1,
x2, 2, -2);
//seq_apply!2u((obj x, int a0, int a1) => { x.setxxx(a0); x.setyyy(a1); },
// x1, 1, -1,
// x2, 2, -2);
}
aW1wb3J0IHN0ZC5zdGRpbzsKCnZvaWQgc2VxX2FwcGx5KHVpbnQgQXJnTnVtLCBGdW5jLCBBcmdzLi4uKShGdW5jIGZ1bmMsIEFyZ3MgYXJncykgewoJZnVuYyhhcmdzWzBdLCBhcmdzWzEgLi4gQXJnTnVtICsgMV0pOwoJc3RhdGljIGlmIChhcmdzLmxlbmd0aCA+IEFyZ051bSArIDEpIHsKCQlzZXFfYXBwbHkhKEFyZ051bSkoZnVuYywgYXJnc1tBcmdOdW0gKyAxIC4uIGFyZ3MubGVuZ3RoXSk7Cgl9Cn0KCmNsYXNzIG9iaiB7Cgl2b2lkIHNldHh4eChpbnQgeCkgewoJCXdyaXRlZmxuKCJzZXR4eHg6ICVkIiwgeCk7Cgl9Cgl2b2lkIHNldHl5eShpbnQgeSkgewoJCXdyaXRlZmxuKCJzZXR5eXk6ICVkIiwgeSk7Cgl9Cn0KCnZvaWQgZihvYmogeCwgaW50IGEwLCBpbnQgYTEpIHsKCSB4LnNldHh4eChhMCk7IHguc2V0eXl5KGExKTsgCn0KCnZvaWQgbWFpbihzdHJpbmdbXSBhcmd2KSB7CglvYmogeDEgPSBuZXcgb2JqKCksIHgyID0gbmV3IG9iaigpOwoJc2VxX2FwcGx5ISgydSkoJmYsCgkJCSAgICAgeDEsIDEsIC0xLAoJCQkgICAgIHgyLCAyLCAtMik7CgkvL3NlcV9hcHBseSEydSgob2JqIHgsIGludCBhMCwgaW50IGExKSA9PiB7IHguc2V0eHh4KGEwKTsgeC5zZXR5eXkoYTEpOyB9LAoJLy8JCSAgICAgeDEsIDEsIC0xLAoJLy8JCSAgICAgeDIsIDIsIC0yKTsKfQo=