Hi Jon, > (de aB (W) (if (idx 'B W T) (inc (car @)) (set W 1))) > (de aC (W) (if (idx 'C W T) (inc (car @)) (set W 1))) > > I then did a couple of (aB 'foo) and then (aC 'foo), and noticed that the use > of aC interferred with the values registered by aB. I think one would need > separate name spaces for aB and aC if one should need to count words in two > separate trees at the same time. Maybe the Rosettacode Word_count example > should > be updated with its own name space. As it is right now, it’s a bit > quick-and-dirty.
Note that it is *not* aB and aC which interfere with each other. The trees are completely separate in 'B' and 'C'. It is the internal symbol 'foo' which you pass to both trees. As you correctly noted, the symbols in the trees are used to hold the values. But if you pass the same symbol, it gets incremented repeatedly. Examples like the rosettacode task do not have this problem, as transient symbols (freshly read from the file) are used. You could pass (name 'foo) to get unique symbols. ♪♫ Alex -- UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe
