[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Trie?
- From: PA <petite.abeille@...>
- Date: Wed, 30 May 2007 20:15:57 +0200
On May 30, 2007, at 10:15, Philippe Lhoste wrote:
On 29/05/2007 18:14, PA wrote:
I'm always curious about, ahem, curiosities... so bring it on :)
Well, it was in my message... :-)
Doh... I was looking for an attachment and overlooked the end of your
email :^)
BTW, there is a dofile that can be commented out, it is my object dump
routine I use for debugging.
To keep you company, here is a rather wacky pseudo implementation
which uses the file system to persist its data structure...
Ah, I missed the "file system" part and was surprised by the lfs.mkdir
calls... Wacky indeed! :-D
Adding a word to the trie builds a directory structure, e.g.:
aTrie[ 'moonstruck' ] = 'moonstruck'
Will create something like ./m/o/o/n/s/t/content.txt
The content file being a serialized Lua table holding all the values
matching a given key (the keys being, hmmm, normalized to ASCII letters
six characters long).
for aKey, aValue in aTrie() do
print( aKey, aValue )
end
> moonst moonstruck
:o)