[Date Prev][Date Next][Thread Prev][Thread Next]
- 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
partial = function (f, i)
local c = function (j)
return f(i, j)
add_one = partial(add, 1)
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.