Skip to content
Prev 52527 / 63421 Next

anonymous function parsing bug?

I think Bill and Luke are failing in trying to make you work out the logic for yourself...

The point is that 
{
  some_computation
}(x)

is an expression that evaluates some_computation and applies it as a function to the argument x (or fails if not a function). 

When you define functions, the body can be a single expression, so

f <- function(a)
{
  some_computation
}(x)

is effectively the same as

f <- function(a) {
 {
   some_computation
 }(x)
}

where you seem to be expecting

{f <- function(a) {
 {
   some_computation
 }
}(x)

Got it?