blob: 10460a2103ae9ee2a5e336811646b7089b300fd3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
--- lam.util --- utility functions
local m = {}
local string = string
local utf8 = require("utf8")
m.luaerror = error
-- signal an error
-- WHERE is where in the process; DESC is a description of the error; the rest
-- are "irritants"
function m.error (desc, ...)
m.luaerror(string.format("%s: %s", desc, table.concat({...}, " ")
))
end
-- remove an element from the front of TBL
function m.pop (tbl)
return table.remove(tbl, 1)
end
function m.tochars (str)
local cs = {}
for _, code in utf8.codes(str) do
table.insert(cs, code)
end
return cs
end
function m.constantly (x)
return function () return x end
end
--------
return m
|