#Penlight Lua Libraries
##Why a new set of libraries?
Penlight brings together a set of generally useful pure Lua modules, focusing on input data handling (such as reading configuration files), functional programming (such as map, reduce, placeholder expressions,etc), and OS path management. Much of the functionality is inspired by the Python standard libraries.
path: queries likeisdir,isfile,exists, splitting paths likedirnameandbasenamedir: listing files in directories (getfiles,getallfiles) and creating/removing directory pathsfile:copy,move; read/write contents withreadandwrite
app:require_hereto rebaserequireto work with main script path; simple argument parsingparse_argslapp: sophisticated usage-text-driven argument parsing for applicationsconfig: flexibly read Unix config files and Windows INI filesstrict: check for undefined global variables - can usestrict.modulefor modulesutils,compat: Penlight support for unified Lua 5.1/5.2 codebasestypes: predicates likeis_callableandis_integer; extendedtypefunction.
utils: can split a string with a delimiter usingutils.splitstringx: extended string functions covering the Pythonstringtypestringio: open strings for reading, and creating strings using standard Lua IO methodslexer: lexical scanner for splitting text into tokens; special cases for Lua and Ctext: indenting and dedenting text, wrapping paragraphs; optionally make%work as in Pythontemplate: small but powerful template expansion enginesip: Simple Input Patterns - higher-level string patterns for parsing text
tablex: copying, comparing and mapping overpretty: pretty-printing Lua tables, and various safe ways to load Lua as dataList: implementation of Python 'list' type - slices, concatenation and partitioningMap,Set,OrderedMap: classes for specialized kinds of tablesData: reading tabular data into 2D arrays and efficient queriesarray2d: operations on 2D arrayspermute: generate permutations
seq: working with iterator pipelines; collecting iterators as tablesclass: a simple reusable class frameworkfunc: symbolic manipulation of expressions and lambda expressionsutils:utils.string_lambdaconverts short strings like '|x| x^2' into functionscomprehension: list comprehensions:C'x for x=1,4'()=={1,2,3,4}
##Requirements
The file and directory functions depend on LuaFileSystem (lfs).
If you want dir.copyfile to work elegantly on Windows, then you need Alien.
Both are present in Lua for Windows.
##Installation
The directory structure is
lua
pl
(module files)
examples
(examples)
tests
(tests)
docs
(index.html)
api
(index.html)
modules
All you need to do is copy the pl directory into your Lua module path, which is typically /usr/local/share/lua/5.1 on a Linux system (of course, you can set LUA_PATH appropriately.)
With Lua for Windows, if LUA stands for 'c:\Program Files\Lua\5.1', then pl goes into LUA\lua, docs goes into LUA\examples\penlight and both examples and tests goes into LUA\examples
##Building the Documentation
Requires ldoc, which is available through LuaRocks. Then it's a simple matter of running ldoc in the docs folder.
Penlight/docs$ ldoc .