Question

What would be the problem of running the following scala codes assuming we are working with dynamic scoping and a global stack to store environments as some variants of Lisp do?

def fact(n:Int,f:() => Int):Int = 
 if(n == 0) f()
 else fact(n-1,() => n*f())
fact(7,() => 1)



def incrementer(x:Int)  = y => y+x
incrementer(2)(3)

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top