Additional question: Should I expect any weird behavior with transient
symbols and the '< or '> operators? E.g. (assuming the symbols have not
been assigned strange values) is it true that "abc" will always be less
than "abd" regardless of the scope of the transient symbols?
On 04/01/2017 03:56 AM, Christopher Howard wrote:
> Ah, okay. Somehow in my mind I had reversed the meaning of "==" and "=".
> @Joh-Tob: I am writing a text-adventure game, using a balanced binary
> tree as the primary data structure for managing game data. I wrote my
> own AA Tree implementation (with guidance from Wikipedia). I see the idx
> and balance functions in PicoLisp reference, but my concern is I don't
> see how you do with those an (efficient) self-balance after single
> inserts to an existing tree, nor how to do self-balancing deletes from
> an existing tree.
> On 04/01/2017 01:46 AM, Alexander Burger wrote:
>> Hi Christopher,
>>> : (aa-search '(("threshold" (("long-description" "You stand in front of
>>> a wooden door, reputed to be the home of one Dr. Theobold. The door has
>>> a small keyhole.") NIL NIL 1)) NIL NIL 1) "threshold")
>>> -> ("threshold" ...
>>> However, if I run this command, I get a different result:
>>> : (aa-search (rooms) "threshold")
>> The problem is the '==' in
>>> (if (== Key (car (aa-kv Tree)))
>> You pass a transient symbol "threshold", and '==' checks for exactly this
>> symbol. The scope of transient symbols is per file or REPL instance, so you
>> the first test probably in the same instance, while "threshold" in the second
>> was a new, different, symbol.
>> Either use '=' for comparison, or use only internal symbols as keys.
>> ♪♫ Alex