mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Added lume.lambda()
This commit is contained in:
parent
4db5a6b683
commit
cf031025fd
8
lume.lua
8
lume.lua
@ -212,6 +212,14 @@ function lume.time(fn, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function lume.lambda(str)
|
||||||
|
local args, body = str:match([[^([%w,_ ]-)%->(.-)$]])
|
||||||
|
assert(args and body, "bad string lambda")
|
||||||
|
local t = { "return function(", args, ")\nreturn ", body, "\nend" }
|
||||||
|
return lume.dostring(table.concat(t))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function lume.serialize(x)
|
function lume.serialize(x)
|
||||||
local f = { string = function(v) return string.format("%q", v) end,
|
local f = { string = function(v) return string.format("%q", v) end,
|
||||||
number = tostring, boolean = tostring }
|
number = tostring, boolean = tostring }
|
||||||
|
Loading…
Reference in New Issue
Block a user