lua-users home
lua-l archive

Re: STL like algorithms for Lua

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Apr 2, 2010 at 3:16 AM, Pan Shi Zhu <pan.shizhu@gmail.com> wrote:
> Hmm, it would be much easier and cleaner to use STL algorithms in lua
> than in c++.
The Penlight seq library has some STL-like functions:
http://stevedonovan.github.com/Penlight/api/modules/pl.seq.html
But classic STL is built around the idea of generalized C++ pointers,
which is not so very applicable to Lua.
What style _is_ appropriate? We had a discussion recently about
standard forms of map and filter, etc. One idea is that these
functions would all take an _iterator_, rather than the table itself:
ls = map(myfun,ipairs(mytable))
But then the thought went, then the output should be an iterator as
well. Which is fine, but then the simple & common case of applying a
function to a list starts looking a little overelaborate, which I
suppose is very much the STL tradition ;)
steve d.

AltStyle によって変換されたページ (->オリジナル) /