[pshaiCmd] ListToStringList

stable
By pshai in Miscellaneous Published April 2021 👁 1,007 views 💬 0 comments

Description

Converts a list of numbers to a list of strings. Example:

local tests = 100
local t

StartTimer()
CC_ListToStringList(ClosePrices())
t = StopTimer()

Log('single run: '..t..'ms')

StartTimer()
for i = 1, tests do
    CC_ListToStringList(ClosePrices())
end
t = StopTimer()

Log(tests..' run(s): '..t..'ms')
HaasScript
-- Author: [email protected]
DefineCommand('ListToStringList', 'Converts a list of numbers to a list of strings')

local numbersList = DefineParameter(ListNumberType, 'numbersList', 'List of numbers to be converted to a list of strings', true, {1, 2, 3, 4}, 'ClosePrices')

local ret = {}

if numbersList and #numbersList > 1 then
    local retLen, v
    for i = 1, #numbersList do
        retLen = #ret
        v = ArrayGet(numbersList, i)
        ret[retLen + 1] = Parse(v, StringType)
    end
end

DefineOutput(ListDynamicType, ret, 'Converted list of strings')

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!