GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||
GeezerVison is showing lua-stdlib.github.io — stdlib Reference stdlibContentsCore Functions
Core LibrariesModule
|
| version | Release version string. |
| assert (expect[, f=''[, ...]]) | Enhance core assert to also allow formatted arguments. |
| eval (s) | Evaluate a string as Lua code. |
| getmetamethod (x, n) | Return named metamethod, if any, otherwise nil. |
| require (module[, min[, too_big[, pattern]]]) | Enhance core require to assert version number compatibility. |
| elems (t) | An iterator over all values of a table. |
| ielems (t) | An iterator over the integer keyed elements of a table. |
| ipairs (t) | An iterator over integer keyed pairs of a sequence. |
| npairs (t) | Ordered iterator for integer keyed values. |
| pairs (t) | Enhance core pairs to respect __pairs even in Lua 5.1. |
| ripairs (t) | An iterator like ipairs, but in reverse. |
| rnpairs (t) | An iterator like npairs, but in reverse. |
| barrel ([namespace=_G]) | A barrel of monkey_patches. |
| ireverse (t) | Return a new table with element order reversed. |
| monkey_patch ([namespace=_G]) | Overwrite core methods with std enhanced versions. |
| tostring (x) | Enhance core tostring to render table contents as a string. |
| __index (name) | Lazy loading of stdlib modules. |
assert to also allow formatted arguments.
std.assert(expect == nil, '100% unexpected!') std.assert(expect == 'expect', '%s the unexpected!', expect)
s
--> 2 std.eval 'math.min(2, 10)'
nil.
The value found at the given key in the metatable of x must be a
function or have its own __call metamethod to qualify as a
callable. Any other value found at key n will cause this function
to return nil.
nil if no metamethod
clone = std.getmetamethod(std.object, '__call')
require to assert version number compatibility.
By default match against the last substring of(dot-delimited)
digits in the module version string.
module.version or
module._VERSION(default: '([%.%d]+)%D*$')
(optional)
-- posix.version == 'posix library for Lua 5.2 / 32' posix = require('posix', '29')
__pairs metamethod, use that to iterate.
--> foo --> bar --> baz --> 5 std.functional.map(print, std.ielems, {'foo', 'bar', [4]='baz', d=5})
If t has a __len metamethod, iterate up to the index it
returns, otherwise up to the first nil.
This function does not support the Lua 5.2 __ipairs metamethod.
--> foo --> bar std.functional.map(print, std.ielems, {'foo', 'bar', [4]='baz', d=5})
Like Lua 5.1 and 5.3, this iterator returns successive key-value
pairs with integer keys starting at 1, up to the first nil valued
pair.
If there is a _len metamethod, keep iterating up to and including
that element, regardless of any intervening nil values.
This function does not support the Lua 5.2 __ipairs metamethod.
--> 1 foo --> 2 bar std.functional.map(print, std.ipairs, {'foo', 'bar', [4]='baz', d=5})
--> 1 foo --> 2 bar --> 3 nil --> 4 baz std.functional.map(print, std.npairs, {'foo', 'bar', [4]='baz', d=5})
pairs to respect __pairs even in Lua 5.1.
--> 1 foo --> 2 bar --> 4 baz --> d 5 std.functional.map(print, std.pairs, {'foo', 'bar', [4]='baz', d=5})
#t + 1--> 2 bar --> 1 foo std.functional.map(print, std.ripairs, {'foo', 'bar', [4]='baz', d=5})
--> 4 baz --> 3 nil --> 2 bar --> 1 foo std.functional.map(print, std.rnpairs, {'foo', 'bar', [4]='baz', d=5})
Apply all monkey_patch functions. Additionally, for backwards
compatibility only, write a selection of sub-module functions into
the given namespace.
local std = require 'std'.barrel()
a new table with integer keyed elements in reverse
order with respect to *t*
local rielems = std.functional.compose(std.ireverse, std.ielems) for e in rielems(l) do process(e) end
std enhanced versions.
Write all functions from this module, except std.barrel and
std.monkey_patch, into the given namespace.
require 'std'.monkey_patch()
tostring to render table contents as a string.
-- {1=baz,foo=bar} print(std.tostring {foo='bar', 'baz'})
the submodule that was loaded to satisfy the missing
`name`, otherwise `nil` if nothing was found
local std = require 'std' local Object = std.object