mc <-
'
functions {
int fibonacci(int x);
int fibonacci(int x) {
if (x <= 0) reject("x must be positive");
return x <= 2 ? 1 : fibonacci(x - 1) + fibonacci(x - 2);
}
}
model {}
'
cppcode <- stanc(model_code = mc, model_name = "Fibonacci")
## Not run: ------------------------------------
# expose_stan_functions(cppcode)
#
## ---------------------------------------------
Run the code above in your browser using DataLab