Function as input into user defined fucntions?

Is it possible in Stan now, or a feature that might be added, to let a function be passed into a user-defined Stan function?

I am thinking I have functions P and Q defined in the functions block, along with some other function R:

`functions{
real P(real X){
real Z;
Z=X+1;
return Z;
}

real Q(real X){
real Z;
Z=X+2;
return Z;
}

real R(function S, real X){
real Z;
Z=S(X);
return Z;
}
}`

and then have something like:
model{ real Y[2] Y[1] = S(P,X); Y[2] = S(Q,X); }

In this example code, it a rather useless request, but in the project I’m working on it would reduce a bunch of code replication.

Not yet, but one of the follow-on projects now that @mitzimorris has refactored the parser is to add proper higher-order types along with closures. Should be feasible both with our underlying type system and with code generation with C++11.

But it’ll probably be a year at least before you see this functionality as we also have tuples, ragged arrays, and sparse matrix types on the to-do list.

Bob,

Thanks for the quick reply! I’ll find a work around for now. I am happy to hear that ragged arrays in the works!