From 3f158ae4b49660d38f02bcca6b08f66fce974c19 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 19 Sep 2018 14:33:34 +0100 Subject: [PATCH] [Minor] Fix selectors iterators operations --- lualib/lua_selectors.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index dbb537010..b39771e33 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -353,7 +353,7 @@ local transform_function = { ['list'] = true, }, ['process'] = function(inp, t) - return inp[1],pure_type(t) + return fun.head(inp),pure_type(t) end, ['description'] = 'Returns the first element', }, @@ -363,7 +363,7 @@ local transform_function = { ['list'] = true, }, ['process'] = function(inp, t) - return inp[#inp],pure_type(t) + return fun.nth(#inp, inp),pure_type(t) end, ['description'] = 'Returns the last element', }, @@ -373,7 +373,7 @@ local transform_function = { ['list'] = true, }, ['process'] = function(inp, t, args) - return inp[tonumber(args[1] or 1)],pure_type(t) + return fun.nth(tonumber(args[1]) or 1, inp),pure_type(t) end, ['description'] = 'Returns the nth element', }, @@ -401,7 +401,7 @@ local transform_function = { ['string_list'] = true }, ['process'] = function(inp, _, args) - return table.concat(inp, args[1] or ''), 'string' + return table.concat(fun.totable(inp), args[1] or ''), 'string' end, ['description'] = 'Joins strings into a single string using separator in the argument', }, @@ -488,7 +488,8 @@ local transform_function = { -- Drops input value and return values from function's arguments or an empty string ['id'] = { ['types'] = { - ['string'] = true + ['string'] = true, + ['list'] = true, }, ['map_type'] = 'string', ['process'] = function(_, _, args) -- 2.39.5