The Raspberry Pi version has a completely new data structure: Association
This is very similar to the dictionary data structure found in many other languages, but it does seem to keep its ordering. A dictionary doesn't seem to bring anything entirely new in possibilities (??), but it does finally give us this data structure without having to use any hacks (like Dispatch or DownValues), which is a big improvement.Question:
Have any of you already found any practical uses for this data structure in your day-to-day work? I'd be curious how people are using it, especially in instances when it makes code significantly nice (shorter or easier to follow). I will need some until I get used to it and it'll become a key part of my active vocabulary, so I'm asking for some ideas/thoughts ...
This data structure seems to be a very natural fit for the output of many functions. It would be very natural for example for Tally and for GatherBy. It seems that instead of keeping the same functionality ties to the same functions, completely new names are made up. For example the twin of Tally is called CountBy
and GatherBy has OrganizeBy
(they're not 100% equivalent but there's a large intersection). Generally, it should be a good output format for many of the "TransformBy" type function I talked about here
and indeed the naming of new functions follows this.
I'm not entirely satisfied with the performance at this moment though. As of today, both GatherBy and Tally seems to perform significantly faster than the Associations versions. Take for example this
implementation and compare the performance to the seemingly entirely equiavalent PositionIndex
. When there are a large number of duplicates, GatherBy is orders of magnitude faster; for no duplicates it's still faster but the difference is much smaller. The same goes for Tally vs CountBy. I'm hoping the performance will be improved eventually.EDIT:
Several of the doc pages mention map-reduce which points at applicatons for distributed computing.