Re:What makes Lua tick?
by plorkyeran on Saturday August 10, 2013 @11:20PM
(#6193698)
Off the top of my head:
Lua only has the third of these three options. I don't really consider this a particularly compelling advantage as a user.
[ Parent
| on HN ]
Re:What makes Lua tick?
by anonymoushn on Sunday August 11, 2013 @03:14AM
(#6194182)
function curry(f,x)
return function(...)
return f(x, ...)
end
end
function reduce(f,t,r)
r = r or t[1]
for i=2,#t do
r = f(r,t[i])
end
return r
end
addf = function(a,b) return a+b end
sum = curry(reduce, addf)
t = {"1", "2", "12"}
print(reduce(addf, t)) -- 15
print(sum(t)) -- 15
res = 0
for i=1,#t do
res = res + t[i]
end
print(res) -- 15
res = 0
for k,v in ipairs(t) do
res = res + v
end
print(res) -- 15No, but I think a lot of python users consider this a particularly compelling advantage as readers.
At least, I know I sure spend a lot more time reading code than I do writing code; so I appreciate any language that tries to optimize for that use-case and helps me minimize my cognitive overhead.