From be68b46a9437a7e4e79f609fa0c87730e337389c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 13 Sep 2018 15:26:42 +0100 Subject: [PATCH] [Minor] Add take_n/drop_n processing functions --- lualib/lua_selectors.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index 66f2906d1..cef2d163f 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -329,6 +329,24 @@ local transform_function = { end, ['description'] = 'Returns the nth element', }, + ['take_n'] = { + ['types'] = { + ['list'] = true, + }, + ['process'] = function(inp, t, args) + return fun.take_n(tonumber(args[1]) or 1, inp),t + end, + ['description'] = 'Returns the n first elements', + }, + ['drop_n'] = { + ['types'] = { + ['list'] = true, + }, + ['process'] = function(inp, t, args) + return fun.drop_n(tonumber(args[1]) or 1, inp),t + end, + ['description'] = 'Returns list without the first n elements', + }, -- Joins strings into a single string using separator in the argument ['join'] = { ['types'] = { -- 2.39.5