lua-users home
lua-l archive

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


On Mon, Dec 20, 2010 at 7:29 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> these libraries, and David Manura has given excellent advice and
> feedback,

Plus some very useful code and tests. In particular, thanks to his
efforts the pl.stringx library has a test suite which exposed some
glaring errors, in particular rstrip and lstrip were wired the wrong
way around (the classic formulation of Murphy's Law)

I've documented his List Comprehension library - at least provided
some examples in-place and pointers to the wiki page and Penlight
Guide.

http://stevedonovan.github.com/Penlight/api/modules/pl.comprehension.html

The key thing to realize about this implementation is that
comprehensions are _functions_, and operate on arguments:

--    dbl = C '2*x for x'
--    dbl {10,20,30}
--    ==> {20,40,60}

He has also contributed a tuple object which is very useful for
testing functions which return multiple results, since it effectively
captures arbitrary argument/result expressions (including nils):

T = require 'pl.test'.tuple

assert(T( ('ab'):find('a') ) == T(1,1))

The more tests, the better. In particular moving away from module()
would have been a nightmare without having the existing tests.

steve d.