> one can use symbols with names like
> For a comparison, access to list is much slower:
> (bench (do 1000000 (inc (nth List 50000))))
> 149.812 sec
> Generation of the symbol names has its price,
> however, for lot of data, it is still faster
> than list access.
Yes, this is a valid approach. Basically you use the symbol lookup
mechanism of 'intern'.
But I see several problems with that:
1. It clobbers the internal symbol name space.
2. There is the danger of conflict with existing symbols
3. The structure can only be cleaned up by calling 'zap' for each symbol
4. If you have many such structures, they will all use the same tree
There is a direct way to achieve something similar: The 'idx' mechanism,
using a binary tree. For example, creating a tree of 50000 random
"array" entries, each initialized to zero:
(def (format (rand 1 50000)) 0)
T ) )
Then, incrementing a million random entries:
(inc (car (idx 'Tree (format (rand 1 50000))))) ) )
This doesn't clobber any global structures. Instead of (off Tree), you
(let Tree NIL
and the whole tree will become garbage as soon as the 'let' body