On Jan 22, 1:14?am, AlexB <4571…@gmail.com> wrote:> i want to be able to call a function by reference, for example:> can i do something that in C would look like:>> void (*f)() = &f1; ?//point f to f1> (*f)(); ?//call f1 via referenceIn q, you essentially already have references to functions. I.e., whenyou write:f:{… some code …}the variable named “f” is bound to a reference to a literal function.You could also bind “f” to a built-in:q)f:+q)f[2;2]4Or make lists of functions:q)fns:(+;*;%;{2*x+y})q)fns[1][333;10]3330
If you can think of symbols as being analogous to C pointers rather
than C++ references, then think of “value” as the q analogue to C’s
dereferencing operator, “*”: