View difference between Paste ID: 9CSNLjCN and 3Mc4M2BS
SHOW: | | - or go back to the newest paste.
1
local dictionary = {}
2
3
local function insertWord(dict, word)
4
	local head, tail = word:upper():match('^(%a)(%a*)$')
5
	if not head then return false; end
6
	if not dict[head] then dict[head] = {}; end
7
	if tail == '' then
8
	else
9
		insertWord(dict[head], tail)
10
	end
11
end
12
13
insertWord(dictionary, 'BAG')