Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
re:RE: st: passing a function name as an argument to another function
From
Christopher Baum <[email protected]>
To
"[email protected]" <[email protected]>
Subject
re:RE: st: passing a function name as an argument to another function
Date
Wed, 24 Aug 2011 10:51:45 -0400
<>
This will definitely work but it means that I'm calling stata routine from mata (my caller procedure is in mata) that does nothing other that passing arguments back to a mata function...not the most beautiful solution I guess but whatever works :)
No need--can be done entirely within Mata. See {m-2] ftof.
clear all
mata:
real function x2(real scalar x)
{
return(x^2)
}
void function test(
pointer(real scalar function) scalar f,
real scalar x)
{
xx = (*f)(x)
xx
}
test(&x2(), 4)
end
Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/