Thanks to everyone for enlightening me about (f)(g). So I
suppose (f)(g)(h)... is OK as long as (f)(g) returns a function with
an argument (and so on)?
Meanwhile, back on Earth, in attempting a compromise between
the clarity of Barry R's
if (cond) names(x) - 10 else dim(x) - 10
and the
Simon Fear wrote:
foo(x) - 10
Error: couldn't find function foo-
this is because you defined 'foo', and not 'foo-', which are two
different functions.
if instead (or as well) you did:
foo- - if (TRUE) get(names-) else get(dim-)
then it works.
Doesn't cure this one though:
(foo)(x) - 10
Richard A. O'Keefe [EMAIL PROTECTED] writes:
Thomas Lumley [EMAIL PROTECTED] wrote:
I would have said that the behavior of
(if (cond) names else dim)(x) - 10
is undefined in the S language, along with things like the order of
evaluation of the apply functions.
On Wed, 3 Sep 2003, Simon Fear wrote:
Thanks to everyone for enlightening me about (f)(g). So I
suppose (f)(g)(h)... is OK as long as (f)(g) returns a function with
an argument (and so on)?
Indeed. As an example of what can be done
recurse - function(f) {
g- function(h)
On Wed, 3 Sep 2003, Richard A. O'Keefe wrote:
Another assignment-related thing I'm not clear on is what
f(x) - e
is supposed to do.
Me neither.
f(x) - e
is equivalent to
x - f-(x, value=e)
and
x - e
assigns to x in the next outer environment,
but a simple
I asked what
x - NULL
(if (TRUE) names else dim)(x) - 27
is *supposed* to do.
Professor Brian Ripley basically gave me the answer I wanted:
it isn't *supposed* to do anything. However, he went on to say
And for R you have the source code, and a `R Language Definition'.
My
Thomas Lumley [EMAIL PROTECTED] writes:
I would have said that the behavior of
(if (cond) names else dim)(x) - 10
is undefined in the S language, along with things like the order of
evaluation of the apply functions.
Actually, following Luke's analysis, I think it is pretty squarely an
Peter Dalgaard BSA wrote:
BTW: If you ever actually need to do something like that, try
eval(substitute(foo(x)-10,list(foo=as.name(if (cond) names else dim
please no!!! What's wrong with:
if(cond){
names(x) - 10
} else {
dim(x) - 10
}
readable, obvious, maintainable,
Barry Rowlingson [EMAIL PROTECTED] writes:
Peter Dalgaard BSA wrote:
BTW: If you ever actually need to do something like that, try
eval(substitute(foo(x)-10,list(foo=as.name(if (cond) names else
dim
please no!!! What's wrong with:
if(cond){
names(x) - 10
} else {
Thomas Lumley [EMAIL PROTECTED] wrote:
I would have said that the behavior of
(if (cond) names else dim)(x) - 10
is undefined in the S language, along with things like the order of
evaluation of the apply functions.
The thing is, it would make perfect
10 matches
Mail list logo