Static and Dynamic Scoping Example
Determine the result of this program using
val x = 1
val y = 2
def p() = x + y
def q(p: Int => Int) = p(x * y)
def f = {
val x = 2
q(p + _)
}
def g(q: Int => Int) = {
val y = 3
def p() = x - y
q(f)
}
print(g(_ + 2))