61,357 reputation
6185278
bio website mathprogramming-intro.org
location St. Petersburg, Russia
age 38
visits member for 2 years, 11 months
seen 1 hour ago

Ok, an obligatory note: opinions expressed here are mine and not those of my employer.


2d
awarded  Nice Answer
2d
comment Difference between Association and Dispatch
@Murta Ok, done as requested.
2d
answered Difference between Association and Dispatch
2d
comment Difference between Association and Dispatch
@alancalvitti Can't say, too little information. Associations can hold millions of key-value pairs easily, but are not too memory-efficient. It all depends on how large the total number of key-value pairs is, and whether or not it is feasible to store them in an Association in memory. There are other factors too.
2d
comment Difference between Association and Dispatch
If you are not going to change your list of rules after you construct them, Dispatch is pretty good. The main difference is that it is cheap to add new key-value pairs to associations, constructing new associations - not so with Dispatch. You can somewhat emulate the action of Dispatch-ed rules on a list of elements, by using Lookup with Associations. Lookup can take a list of keys. It has also optional argument for a default value. Not sure if it can do both at the same time, don't remember.
Dec
12
comment Function that returns the second argument of Reap
@halirutan Yep, same feelings here. +1.
Dec
12
comment Function that returns the second argument of Reap
Reap is not a simple function. It is closer to scoping constructs in spirit. It has a Hold attribute, so that the code evaluates only inside of it, but not before being passed. You need to set HoldAll or HoldFirst attribute to your Reap2, if you want it to behave properly.
Dec
9
awarded  Good Answer
Dec
6
awarded  Nice Answer
Dec
6
comment SetAttributes to Cases creates problem in Suggestions Bar
To add to the comment above by @halirutan: generally, when you globally change system functions, either by overloading them or by changing their set of attributes, all bets are off. Here is some discussion for the alternatives of doing it.
Dec
3
awarded  Guru
Dec
2
comment Can a Trie be implemented efficiently?
@alancalvitti This only means the Import is grossly inefficient. Also, list of Associations is by itself not the most efficient format. It has nothing to do with data structures, they must be implemented as efficiently as possible.
Nov
30
comment Can a Trie be implemented efficiently?
@Rojo Thanks for the vote, but the credit goes to Association and those desinged and who implemented it. I only had to stick it in two places. Besides, I could as well use Dispatch in my original code, likely with a similar effect.
Nov
29
awarded  Nice Answer
Nov
28
comment Can a Trie be implemented efficiently?
@alancalvitti ... one should not be mixing them. Dataset is a kind of a database, and defines its own query language. Which data structures it uses under the hood is its own business, and the end user could not care less, as long as the speed and convenience is satisfactory. Trie and others are particular data structures. They are constructed to be used in very specific algorithms. They are not general by definition. Asking your database engine to be at the same time a collection of data structures / algorithms doesn't strike me as a good idea. This has been my last comment here.
Nov
28
comment Can a Trie be implemented efficiently?
@alancalvitti You seem to not be getting my point, despite my numerous attempts to make it clear. I do not dispute the usefulness of uniform wrapper. And I don't claim my code (or the approach to data structures implementation and design I advocate) to provide generic wrappers. I was just saying that a question about a design of a particular data structure like a trie (the one asked in this page) is largely unrelated to the one of designing uniform wrappers to incorporate many data structures under some uniform syntactic umbrella. These are different layers of abstraction, and ...
Nov
28
comment Can a Trie be implemented efficiently?
@alancalvitti I understand your perspective as being a user who wants compact syntax, but for any realistic problem this is not the only dimension. What I have described is a developer's view on how to structure the functionality so that it works well for both performance and convenience dimensions. From this viewpoint, Dataset certainly is a wrapper (in the sense I explained above). Once again: I am not saying that convenience isn't important, I am saying that it is a different aspect, from pure data structure implementation.
Nov
28
comment Can a Trie be implemented efficiently?
@alancalvitti ... type-checks data, etc.). But, I insist on the separation of data structures and syntactic layer. Association itself is a new efficient data structure, and it was implemented in C for speed. Even when we implement new data structures in Mathematica (top-level), they must be made as fast as possible. Only then, one adds syntactic layer on top, as a separate step. Both are important, but the core data structures should not IMO be concerned with syntactic convenience - they just need to be fast and have a clear well-defined API.
Nov
28
comment Can a Trie be implemented efficiently?
@alancalvitti The reality of Mathematica is that every generalization potentially leads to a serious loss of performance. The language is so high-level, that we don't gain the performance, we can only not lose or lose minimally. Therefore, the utmost concern of the implementor of a generic functionality in Mathematica is performance. I speak from personal experience here. Now, wrapping data structures into wrappers like Dataset, which provide convenient syntax, is a separate step. I don't mean to say that Dataset is just a wrapper, because it is not (it generates powerful queries, ...
Nov
28
comment Can a Trie be implemented efficiently?
@alancalvitti My point has been that it is important to distinguish different aspects. Trie by itself is a specialized data structure, and as such, should be "mean and lean": efficient in the first place, and having some simple well-defined API. How to make it syntactically more pleasant is a different question. One may use Dataset, or some custom wrappers, or whatever. But when things get mixed, the result is that it is much harder to understand performance. In the context of Mathematica, this is particularly important.