1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-17 16:47:22 +03:00

lua: add conj

This commit is contained in:
Mitsuru Kariya 2015-07-22 17:56:32 +09:00
parent abbd36483f
commit 1ad8d5018d

View File

@ -159,6 +159,20 @@ function swap_BANG(atm,f,...)
return atm.val
end
local function conj(obj, ...)
local new_obj = types.copy(obj)
if types._list_Q(new_obj) then
for i, v in ipairs(arg) do
table.insert(new_obj, 1, v)
end
else
for i, v in ipairs(arg) do
table.insert(new_obj, v)
end
end
return new_obj
end
M.ns = {
['='] = types._equal_Q,
throw = types.throw,
@ -213,7 +227,7 @@ M.ns = {
count = function(a) return #a end,
apply = apply,
map = map,
conj = function(...) return Nil end,
conj = conj,
meta = meta,
['with-meta'] = with_meta,