lua-users home
lua-l archive

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


I'm new to the mailing list, so let me know if I'm inadvertently doing anything wrong. If I am, sorry about that :P

I was wondering if there is a posiblity of expanding the Lua standard library (mostly the string and table library). There are a few basic utility functions that I was hoping could be added to improve usability out of the box:

- capitalize
- split (this one I think is much needed. I'm constently rewriting myself split functions).
- strip (also write myself a lot of whitespace striping functions)
- insert

- any (the same as any? in Ruby)
- join (same as split)
- select (a filter function that can either accept a value or a function)
- shuffle (can be used to get a random value too, i.e `({1,2,3}):shuffle[1]`)

I was heavily inspired by Ruby's standard library, but tried to avoid adding functions that are just simple aliases. My rule was, if it can't be done in one line of Lua code, write a new function for it.

I've implemented all of these functions in a patch: There's a TODO here and there, but it mostly works (the C API is awesome!).

These functions would mean less boilerplate, faster code (since the standard library is implemented in C) and better readability. Let me know what you guys think :)

- Charles