3 ms·
It is rather interesting to look at Paul's list of implementations of an accmulator in different languages: http://www.paulgraham.com/accgen.html http://www.p
by andersholtsberg 19y ago
It is rather interesting to look at Paul's list of
implementations of an accmulator in different languages:
http://www.paulgraham.com/accgen.html http://www.paulgraham.com/accgen.html
In my very biased and unlearned view the simplest readable
versions are Javascript and Lua. And Lua has server side
libraries for CGI and SQL and other goodies (search for
Xavante on the net). Just a tip for those poking around
for readable and clean language alternatives. And Lua just
got up to position 18 on the Tiobe index this month.
http://www.tiobe.com/tpci.htm http://www.tiobe.com/tpci.htm
Hackers and Paiter page 161, The hundred years language:
"How far will this flattening of data structures go? I can
think of possibilities that shock even me, with my
consiously broadened mind. Will we get rid of arrays for
example? After all, they're just a subset of hash tables
where the keys are vectors of integers."
Lua does exactly this. And is quite efficient anyway.
Anders Holtsberg
- portLAN 19y ago> In my very biased and unlearned view the simplest readable versions are Javascript and Lua. The Python version listed there doesn't actually meet the requirement (it doesn't return a function, it returns a class instance, and it keeps modifying n every time it's called). Corrected version: def foo(n): return lambda (i): n+i Which is essentially identical to the Common Lisp version.
- earthboundkid 19y agoIf it's supposed to be an accumulator, I take it they want the value of n to be changed each time. I'd do: def acc(n): while True: n += yield n
- portLAN 19y agoBut emphasizing correctness makes my one-liner not work! And reading the original I can see this whole issue was already covered! BTW, generators are non-callable.