π‘ R and
#Perl are more alike than you think!Both use lexical scoping to create closures. The inner function "captures" the variable from the outer scope, creating a persistent environment.
#rstats
plus <- function(x) {
function(y) x + y
}
plus_one <- plus(1)
plus_one(10) #11
1/