[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: partial evaluation
- From: paul@...
- Date: Thu, 2 Nov 2000 11:18:22 +0800
I have the following code:
---------
add = function (x, y)
return x + y
end
partial = function (f, i)
local c = function (j)
return f(i, j)
end
return c
end
add_one = partial(add, 1)
print (add_one(2))
---------
But Lua says
error: cannot access a variable in outer scope;
last token read: `f' at line 7 in file `a.lua'
It is no surprise that Lua does not suport partial function
evaluation, but is there any chance to get around with this
variable scope problem?
I've always find anonymous function very powerful if you
can compose function with function freely, as commonly seen
in functional languages.
Regards,
.paul.