Line 34: |
Line 34: |
| return final | | return final |
| end | | end |
| + | |
| + | -- destructively |
| + | function p.mergeTable(t1,t2) |
| + | for k,v in pairs(t2) do |
| + | if type(v) == "table" then |
| + | if type(t1[k] or false) == "table" then |
| + | tableMerge(t1[k] or {}, t2[k] or {}) |
| + | else |
| + | t1[k] = v |
| + | end |
| + | else |
| + | t1[k] = v |
| + | end |
| + | end |
| + | return t1 |
| + | end |
| + | |
| + | -- Assumes a1 and a2 are "arrays" with their keys being ints in increasing order from 1 |
| + | -- returns array with a2's indexes being appended to a1 in order |
| + | function p.mergeArrays(a1,a2) |
| + | local len = #a1 |
| + | for i,v in pairs(a2) do |
| + | a1[len+i] = v |
| + | end |
| + | return a1 |
| + | end |
| + | |
| + | p.lowerCase = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"} |
| + | p.upperCase = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"} |
| + | p.letters = p.mergeArrays(p.lowerCase,p.upperCase) |
| | | |
| | | |