Skip to content

Instantly share code, notes, and snippets.

@yatsuta
Forked from kohta/gist:561754
Created September 2, 2010 06:27
Show Gist options
  • Save yatsuta/561953 to your computer and use it in GitHub Desktop.
Save yatsuta/561953 to your computer and use it in GitHub Desktop.
f <- function(x){x**2}
fgen <- function(k){
k # for forcing arg k
return(function(x){
f(k*x)
})
}
generatedfuncs <- lapply(c(1:4),fgen)
evaluatedfuncs <- lapply(generatedfuncs,function(g){g(1)})
print(evaluatedfuncs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment