strlstlen

function strlstlen( lst ) --> len

Description

Receives a string list and returns the accumulated length of all strings.

Parameters

lst

An array table with strings.

Return Values

len

The accumulated length of all strings.

Code

--ZFUNC-strlstlen-v1
local function strlstlen( lst ) --> len
   local len = 0
   for _, str in ipairs( lst ) do
      len = len + string.len( str )
   end
   return len
end

return strlstlen

Examples

local t = require( "tapered" )
local strlstlen = require( "strlstlen" )

t.is( 0, strlstlen{ "", "", "", "" } )
t.is( 8, strlstlen{ "abc", "def", "", "gh" } )

t.done()