On Sun, Aug 23, 2009 at 05:38:10PM -0400, John Cowan wrote: > Alaric Snell-Pym scripsit: > > > Is that necessarily the best solution to your problem, though? > > Anything with an identity (a cons cell, for example) will work as a > > 'token' for a-list lookups? > > The idea is to speed up string lookups. Currently the a-list maps strings > to values, which means I must use assoc to search it. If it mapped > symbols to values instead, I could use the faster assq. I'd rather intern > the strings once and have done, but I don't want to cause a memory leak.
If you're going to have a *lot* of these strings (and you are, or you wouldn't be worried about the GC angle), then you could be better off with a "real" hash table or r/b-tree or similar structure. Even with the assoc -> assq conversion your search is still O(N), when it could be O(logN) or O(1). No? Cheers, -- Andrew _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
