I'm wondering if there is an implementation of a first class dictionary data structure available for use in the Logo language? I don't see one available in the documentation of UCB Logo or FMS Logo. I see that there are property lists, but those don't appear to be first class, and it looks like they are linear look-up association lists. I'm looking for something based on hashes or trees. It seems like there have been lots of historical Logos out there, and maybe someone has implemented something like this. Also, if anyone knows of a repository of Logo code, I'd appreciate the pointers (i.e. CPAN for Logo).
A dictionary data structure in the Logo language (key/value store)
312 Views Asked by Greg Buchholz At
2
There are 2 best solutions below
0
On
It is true that in FMSLogo property lists are not first class citizens. However, property list "names" are first class. Also version 6.32.0 of FMSLogo does implement property lists as AVL trees. This is documented here: http://sourceforge.net/p/fmslogo/feature-requests/94/
Here's a real simplistic purely-functional tree implementation based on lists. Keys can be words or numbers. The empty list is the empty dictionary. It isn't self balancing so you'll have to call "rebalance" yourself to after doing inserts with "dict_add". Don't do that a lot since "rebalance" as implemented takes O(n) time. A procedure "testing" exercises things a little bit.