mirror of
https://github.com/kanaka/mal.git
synced 2024-09-19 09:38:28 +03:00
lua: add conj
This commit is contained in:
parent
abbd36483f
commit
1ad8d5018d
16
lua/core.lua
16
lua/core.lua
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user