While the Lua reference manual is indispensable, here are the most important parts of Lua you'll need to get started. This is meant to give a very brief overview and let you know where in the manual to look for further details, not to teach Lua.
tonumber: converts its string argument to a number; takes optional basetostring: converts its argument to a stringprint: printstostringof all its arguments separated by tab characterstype: returns a string describing the type of its argumentpcall: calls a function in protected mode so errors are not fatalerror: halts execution and break to the nearestpcallassert: raises an error if a condition is nil or falseipairs: iterates over sequential tablespairs: iterates over any table, sequential or not, in undefined orderunpack: turns a sequential table into multiple valuesrequire: loads and returns a given module
Note that tostring on tables will give unsatisfactory results; you
will want to use fennelview or another pretty-printer for debugging
and development.
You can explore a module with (each [k v (pairs math)] (print k v))
in the repl to see all the functions and values it contains.
math: all your standard math things including trig andrandomtable:concat,insert,remove, andsortare the main thingsstring: all common string operations (exceptsplitwhich is absent)io: mostly filesystem functions (directory listing is notably absent)os: operating system functions likeexit,time,getenv, etc
In particular table.insert and table.remove are intended for
sequential tables; they will shift over the indices of every element
after the specified index. To remove something from a non-sequential
table simply set the field to nil.
Note that Lua does not implement regular expressions but its own more
limited pattern language for
string.find, string.match, etc.
getfenv/setfenv: access to first-class function environments in Lua 5.1; in 5.2 onward use the _ENV table insteadgetmetatable/setmetatable: metatables allow you to override the behavior of tables in flexible ways with functions of your choicecoroutine: the coroutine module allows you to do flexible control transfer in a first-class waypackage: this module tracks and controls the loading of modulesarg: table of command-line arguments passed to the process...: arguments passed to the current function; acts as multiple valuesselect: most commonly used with...to find the number of argumentsxpcall: acts likepcallbut accepts a handler; used to get a full stack trace rather than a single line number for errors
These are used for loading Lua code. The load* functions return a
"chunk" function which must be called before the code gets run, but
dofile executes immediately.
dofileloadloadfileloadstring
_G: a table of all globals_VERSION: the current version of Lua being used as a stringcollectgarbage: you hopefully will never need thisdebug: see the Lua manual for this modulenext: needed for implementing your own iteratorsrawequal/rawget/rawlen/rawset: operations which bypass metatables