Hi All,

I've just recently discovered the cmpfun function, and was wanting to to
create a function to assign this to all the functions i have created, but
without explicitly naming them.

I've achieved this with:

foo <- function(x) { print(x)}
bar <- function(x) { print(x + 1)}

> foo <- function(x) { print(x)}
> foo
function(x) { print(x)}
> cmpfun(foo)
function(x) { print(x)}
<bytecode: 0x26e3d40>
>

find.all.functions <- ls.str(mode = 'function')
 for(i in seq_along(find.all.functions)) {
    assign(find.all.functions[i], cmpfun(get(find.all.functions[i])))
  }

But remember told that using assign is generally a bad idea, and ideally i
want to functionalize this to say something like:

CreateCompiledFunctions <- function() {
  find.all.functions <- ls.str(mode = 'function')
  for(i in seq_along(find.all.functions)) {
    assign(find.all.functions[i], cmpfun(get(find.all.functions[i])))
  }
}


Does anyone have a better solution?

Thanks in advance

Mike

	[[alternative HTML version deleted]]

