56,282 reputation
5158249
bio website mathprogramming-intro.org
location St. Petersburg, Russia
age 37
visits member for 2 years, 6 months
seen 16 mins ago

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


Jul
10
comment How to make use of Associations?
Someone upvoted after a few seconds of this being posted. Either this is a new speed record in reading, or some people have too much trust in me :)
Jul
10
answered How to make use of Associations?
Jul
2
comment How to implement nested With as a single construct using functional programming (Fold)?
No problem at all.
Jul
2
comment How to implement nested With as a single construct using functional programming (Fold)?
Also, technically, Fold does not implement recursion. It actually does the opposite - it kills it, for a rather small subset of all cases where recursion can be used. There are lots of more complex cases where recursion can not be reduced to Fold. And I personally view recursion cleaner and more idiomatic, in lots of cases. And, as I said, strictly more powerful than Fold. This is not to say that I don't appreciate Fold - if you look at the code I posted on this site, you'll see that I use Fold rather frequently.
Jul
2
comment How to implement nested With as a single construct using functional programming (Fold)?
This is not a simple recursion, it is combined with evaluation control. In other words, it is recursive code generation, and you have to think about evaluation. I see absolutely no advantage in using Fold here, but at the point where you start being interested not in just having a solution to the problem, but having it in a specific way, it all becomes speculative. So, in this new formulation I'd consider this either opinion-based, or too narrow. Technically, I don't see here anything deeper than just another exercise in evaluation control. But may be I am wrong. Let's see what others think.
Jul
2
comment How to implement nested With as a single construct using functional programming (Fold)?
Yes, there is, but this will be less natural / harder / less elegant. Since the resulting code expansion is a nested With, recursion is IMO the most natural road to proceed here.
Jul
1
awarded  Guru
Jul
1
comment What's a non-trivial Mathematica program involving conscious choice of stack vs. queue data structure?
The example of a trie used to implement prefix word search here, and particularly its application to the Boggle problem are I think good examples where the right choice of data structures was crucial. The first one also uses a stack to collect letters for words, while the last one also uses linked lists to store partial results.
Jun
30
awarded  Informed
Jun
28
comment String templating
@Szabolcs I had similar strategy for Composition, having instead used my own version of it which wasn't unpacking. I wasn't aware of the fact that Composition no longer unpacks. I just checked on the dev.version, and yes, you are right. Thanks for pointing this out. There is (at least) one more issue with Composition, which is good to know, and which I have discussed here in the section "Fixing some speed problems". I did not re-test now, but it is probably still there.
Jun
28
awarded  Good Answer
Jun
28
awarded  Nice Answer
Jun
28
comment Building sparse array from packed arrays
@VanillaSpinIce Not that I know of (which doesn't mean there isn't). It seems that the unpacking is done in the internal code, which constructs the sparse array. I wrote some code which constructs the sparse array from pieces at lower level, but the unpacking was still there - thus I did not post it.
Jun
28
comment Performance tuning in Mathematica?
@bobthechemist Thanks, updated.
Jun
28
revised Performance tuning in Mathematica?
Added a mention of Associations
Jun
27
comment Building sparse array from packed arrays
It looks like there is some internal unpacking going on, for large enough lists. It is possible to construct the pieces of the SparseArray without unpacking, but it looks like they are still unpacked internally.
Jun
27
comment Building sparse array from packed arrays
There is unpacking if you try this on larger arrays, of e.g. 100 elements. But to see it, you have to enable On["Packing"] before running the code.
Jun
26
comment String templating
@Kuba I agree. I don't consider this style the most powerful (in the sense that it does not really allow to introduce qualitatively more powerful abstractions), but it can be applied to the majority of tasks where Mathematica shines, and it is still considerably more expressive that the "usual" one where component functions are not singled out explicitly.
Jun
26
comment String templating
+1 for using the Composition-style code. It had become my preferred style too, some time ago. New operator forms (curried functions) for many built-in functions in V10 makes this even much easier to use.
Jun
26
comment Is learning haskell still necessary to MMA users?
I actually think that someone who knows one or a few general-purpose functional languages really well, can quickly become really good in Mma too. The sooner you broaden out, the better programmer you become, in Mma or other language. The important thing IMO is to become pragmatic and clearly see advantages and flaws of any given language / tool, for a given task. Also, one needs to be able to distinguish real problems, inherent to the task at hand, and problems generated by the system or language being used, which have nothing to do with the essence of your task / problem proper.