>Despite the fact that list 'n' hashes are very common, there are times I wish I was using a thoughtful tree representation. Such a model can provide richer navigation operations.
Specter[1] provides something like this for Clojure, allowing rich navigation and transformation abilities to deeply nested structures.
I've thought about this topic a lot recently. Many times I find myself working with API endpoints which return deeply nested JSON or XML "documents" which I have no real desire to learn their schema. (AWS and ElastiSearch)
I ended up creating a Python Library to perform key lookups on these deeply nested documents. For Example:
I've always wanted to write something like regular expressions for lists of objects. So, for example the example of writing a parser, one could use a regex to match chars to tokens, then write another that gathers tokens into blocks and etc. Essentially, bottom-up parsing without resorting to parser generators that take over everything. A similar tool would be interesting for querying trees directly.
That is definitely very interesting! Writing a parser/compiler for 'x' language tends to be a component of many interesting projects, and that's definitely a good start -- thanks :)
Going into it I assumed this article was about data structures like the PHP "array", which are basically ordered hashtables that allow the programmer to treat them like either lists or hashes depending on context and still get reasonable performance. (I haven't seen this pattern used much elsewhere, has anyone?)
Lua tables are similar- they're nominally hash tables but are often used as arrays (including a length operator), and a few versions ago they added an optimization where small integer keys are stored in an actual linear array.
Aren't any hashes that keep track of order like that? (I.e. how's that different than objects in javascript, hashes in ruby, OrderedDicts in python and LinkedHashmaps in java?)
I wonder if the .Net/Java approach of "Iterables And Objects" with generic sequence operators either is ListAndHash or is the equivalent in more strongly typed languages. You essentially replace String->Object Hashes with Objects and Lambda lookup functions.
Finding out about "alists" and their lispy incarnation made me so happy. It was just so neat that something in some regards more capable than a typical hash table (key shadowing, references needn't be to the entire structure, ...) could spring to life, expressed in terms of barely anything atop the humble cons cell.
Yeah, but now that trivial observation has a name that he coined.
And incidentally, what a terrible name. A "hash" (really hash table) is a specific implementation of a map/dictionary. You shouldn't use "hash" to refer to a map based on search trees.
It is interesting that hash is sometimes (incorrectly) used as a synonym or generic name for map/dictionaty/associative array, but Red-Black-Tree, AVL tree, etc. is not.
Specter[1] provides something like this for Clojure, allowing rich navigation and transformation abilities to deeply nested structures.
[1]: http://nathanmarz.com/blog/functional-navigational-programmi...