Created
March 12, 2015 23:58
-
-
Save nefftd/e7209526130609e98f08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function characters_to_array(str, length) | |
-- Returns an array where every (length) character are split into a new field | |
-- of said array. | |
if #str == 0 then return {} end | |
local a,i = {},1 | |
repeat | |
a[i] = str:sub(1,length) | |
i = i + 1 | |
str = str:sub(length+1) | |
until str == '' | |
return a | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment