Dear all,
I am trying to create a pointer that points to different functions (e.g., max, min, sum, mean). However, when it is pointing to function sum(), I got an error.
The error says
I found a way around it by creating a wrapper function like the one below, but I still would like to know why built-in functions do not allow to be ‘pointed’ and if there is a more elegant way to solve this issue.
Thanks,
I am trying to create a pointer that points to different functions (e.g., max, min, sum, mean). However, when it is pointing to function sum(), I got an error.
Code:
mata: func = &max() // works fine func = &min() // works fine func = &mean() // works fine func = &sum() // <-- ERROR end
Code:
sum() built-in, may not evaluate address (0 lines skipped)
Code:
function _msum(numeric matrix Z) { real matrix T T = sum(Z) return(T) }
Comment