alestane icon

Dictionary tree (recurse)

alestane | PRO | 02/03/14 03:12:16 PM UTC | 0 ⭐ | 334 👁️ | Never ⏰ | []
Lua |

300 B

|

None

|

0 👍

/

0 👎

local dictionary = {}
 
local function insertWord(dict, word)
    local head, tail = word:upper():match('^(%a)(%a*)$')
    if not head then return false; end
    if not dict[head] then dict[head] = {}; end
    if tail == '' then
    else
        insertWord(dict[head], tail)
    end
end
 
insertWord(dictionary, 'BAG')

Comments