[Rd] How do you construct a function from a list?

Duncan Murdoch murdoch@stats.uwo.ca
Wed, 22 Nov 2000 09:24:49 -0500


On 22 Nov 2000 13:35:47 +0100, Peter Dalgaard  wrote in message
<x2n1esp4kc.fsf@blueberry.kubism.ku.dk>:

>He is, but this (do_asfunction in coerce.c) looks wrong:
>
>    if( n == 1 )
>        args =  mkCLOSXP(args, arglist, envir);
>    else
>        args =  mkCLOSXP(args, VECTOR_ELT(arglist, n - 1), envir);
>    UNPROTECT(1);

I just posted a bug report about how
"as.function(as.list(somefunction))" doesn't return the function
properly.  Sometimes it does:

 > options(keep.source = F) 
 > noarg _ function() 1
 > noarg
 function () 
 1
 > as.function(as.list(noarg))
 function () 
 1

So it depends on the type of body whether as.function works properly.

Duncan Murdoch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._