The to_int()
function is only available in the most recent release of Stan (2.31), the error above indicates that you’re using an older version.
If you’re not able to update, there’s an example of a basic Stan function for doing that here: Factorial, tgamma & matrix building - #2 by andrjohns