R:Okay. That's not what I was expecting.
> a <- "Yes"
> f <- function() { return(a) }
> a <- "No"
> f()
[1] "No"
Scheme:Hm. But (in R):
> (define a "Yes")
> (define f (lambda () a))
> (define a "No")
> (f)
"No"
> f <- (function() {a <- "What?"; list(yes = function() a <- "Yes!", huh = function() cat(a, "\n"))})()
> f$huh()
What?
> f$yes()
> f$huh()
What?
I guess I'll have to take a look at the manual to see exactly what <- means.
No comments:
Post a Comment