Reputation
Next tag badge:
209/100 score
19/20 answers
Badges
6 195 287
Newest
 Nice Answer
Impact
~420k people reached

Feb
11
comment Read and filter a text file without importing
Have a look at this question. There are a number of solutions shown there, which you might be able to adopt to your situation. All of them will however require to write some custom code.
Feb
11
comment Counting the population of integers
@jVincent To summarize - and this is my last comment on this matter: the beef I have with your approach to benchmarking is that you present benchmarks which are accurate only for a very narrow subset of all possible cases where functions in question can be used (namely, functions used on smallish toy lists, but in a large loop). To my mind, such benchmarks are of limited utility. Also, if you present them / argue about efficiency, you have to always state under which conditions your conclusions are correct - which you did not do, as far as I am concerned.
Feb
11
comment Counting the population of integers
@jVincent "If you have a loop that constantly performs operation f[input,100], it doesn't matter if f[x,n] is O(n) and g[x,n] is O(n^2), you might still have f be the faster solution.`" - right, this is the core of why I find your approach problematic. The statement is correct, but why do you think that this is the main use case for this function? Had the OP faced a problem having this in a large loop, he'd say so in the question. This is not what most people imply when ask to optimize a function. If they need to optimize code in a loop, they would say so.
Feb
11
comment Counting the population of integers
@jVincent For a fixed and small number of unique elements, your benchmarks may make some sense (although this is hardly a general case for this problem). But even in this case, instead of simply repeating the code 10000 times, I would increase the lengths of individual sublists, over which you are counting. This is important, because Count is a pattern-based function. For long sub-lists, Tally shows its advantages. Keeping sublists small as you do in your tests, you measure anything but the interesting parts. So, even in your narrowed formulation, your benchmarking is seriously flawed.
Feb
11
comment Counting the population of integers
@jVincent ... code run on a toy list in question. This is not what Mr.Wizard and myself meant by discussing efficiency, and I dare to say this is not what most people mean by efficiency either. It's probably third time for this post that I am trying to explain this to you. I am really starting to think that you have never yet faced a real-world code optimization problems, otherwise you would know what I mean. You don't have to go far: browse the questions in performance-tuning tag here, and see how benchmarking is typically done, and what people mean by efficiency.
Feb
11
comment Counting the population of integers
@jVincent You seem to not be getting it, even after both myself and Mr.Wizard tried our best to explain. Your tests via running the code 10000 times on the small toy lists are meaningless, because at that scale what you measure is determined not by the true complexity of an algorithm, but by things that become irrelevant for real list samples. Have a look at Mr.Wizard's benchmarks, for more or less real benchmarking. So, to reiterate once again: your statement is correct, but is only meaningful if the OP will only ever be interested in speeding up code consisting of 10000 iterations of a ...
Feb
11
comment Counting the population of integers
@Mr.Wizard Have a look at my new version.
Feb
11
revised Counting the population of integers
Added a (much) faster solution
Feb
11
comment Counting the population of integers
Thanks for this comparison. My method "blows up"not because of Tally, but because of Alternatives@@elems` pattern in my post-processing. This was an oversight from my side and can be improved. I will post faster code soon and ping you then.
Feb
11
awarded  Nice Answer
Feb
10
awarded  Nice Answer
Feb
10
comment What are the known differences between Save and DumpSave, and how to account for them?
My comment certainly does not qualify as an answer, or I would have posted it as such :)
Feb
10
comment Counting the population of integers
This is not to detract from the beauty of your solution. However, it simply can not be generically as fast as Tally, because it repeats Count for any element in the list and any sublist, so is based on a fundamentally worse complexity algorithm. This is a second time I see rather meaningless benchamrks coming from you. I have a very high opinion of you as a Mma programmer, but please pay more attention when posting benchmarks - this is a sensitive topic and we want full objectiveness here. Thanks. And +1 for your solution ( but not benchmarks :-)).
Feb
10
comment Counting the population of integers
What is code? Without knowing it, the timings are IMO largely meaningless. If you repeat 10000 times a function call on a small (toy) list, it tells you nothing about the computational complexity of some solution for sizable lists, meaning that you are benchmarking applications to toy lists only. This is, of course, fine, if one is only interested in being ultra-fast on very small lists, but then chances are that bottlenecks will be elsewhere anyway. Normally, one is more interested in larger lists though, for benchmarking. Perhaps, you used large lists in your code, but how would we know?
Feb
10
comment What are the known differences between Save and DumpSave, and how to account for them?
I have encountered similar problem with Save converting delayed UpValues- based definitions to immediate ones (don't remember which one was the culprit - Save or Get), in this answer. Did not really find time to get deeper into it, but have a look at retrieveMainList function there for a work-around and some comments I made about it.
Feb
9
revised Counting the population of integers
refactored the code to minimally change the original OP's approach
Feb
9
answered Counting the population of integers
Feb
9
comment Efficient code for tallying entries in very large lists
@hailekofi ... provided by an iterator. So, you construct some function f which, when called as f[], returns the next result from your collection or set you want to iterate through. Then, the iterator in this setup is iterator[f]. From this point on, the rest of the code knows what to do with this, without being concerned with exactly how your iterator function f works.
Feb
9
comment Efficient code for tallying entries in very large lists
@hailekofi Thanks for the accept :-). I used this opportunity to connect to some of the things I've done earlier. Re: iterator - this is just an abstraction, a data type, if you wish. It is created along the lines of this answer of mine. So, yes, it is a task of the user to construct an iteator for any given specific situation. Basically, the only requirement here is that iterator contains a function which, when called with zero arguments, returns some result. This result will be interpreted as "next" value ...
Feb
9
comment Is Table the only functional way to construct nested loops in Mathematica?
@RunnyKine Right, it is a good habit to not accept immediately. This would motivate others to contribute more answers.