61,447 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.


Nov
5
revised Mathematica taking too long to calculate recursive function
added 220 characters in body
Nov
5
comment Mathematica taking too long to calculate recursive function
@MichaelE2 Will do, thanks. But have a look at my edit, I also fixed the recursive code.
Nov
5
revised Mathematica taking too long to calculate recursive function
added 220 characters in body
Nov
5
revised Mathematica taking too long to calculate recursive function
added 220 characters in body
Nov
5
answered Mathematica taking too long to calculate recursive function
Nov
5
comment A smarter nested With?
@TeakeNutma because I wrapped symbols in HoldPattern, and use Unevaluated for the rhs. HoldPattern is exactly the right tool for the job here, since it is invisible to the pattern-matcher (and so FreeQ works fine).
Nov
5
comment A smarter nested With?
@Mr.Wizard I guess, the idea is that we want to avoid user-defined functions in expanded code in definitions, both for efficiency reasons and because we may want to attach conditions. As to With vs Module, With is cleaner (manifestly no side effects), when one knows that variables won't change in the body.
Nov
5
comment A smarter nested With?
@MichaelE2 Thanks for double-checking. I've not done this sort of things for some while, got a bit rusty.
Nov
5
comment A smarter nested With?
@MichaelE2 That was an evaluation leak, thanks for reporting. I seem to have fixed it, although perhaps not very elegantly.
Nov
5
revised A smarter nested With?
Fixed the evaluation leak
Nov
5
answered Variable that changes itself
Nov
5
answered A smarter nested With?
Nov
5
revised Mathematica periodic moving map
Added a more general case
Nov
5
answered Mathematica periodic moving map
Nov
5
awarded  Nice Answer
Nov
4
comment How can a field be efficiently added to a Dataset?
@b.gatessucks Indeed, it looks like this operation must be built-in.
Nov
4
comment How can a field be efficiently added to a Dataset?
@b.gatessucks It's a bit harder. This is what I came up with (used consecutive integers for distances, to make it simple): ds[tr /* Append["distance" -> AssociationThread[Normal@ds[Keys], {1, 2, 3, 4, 5, 6, 7, 8}]] /* tr]
Nov
3
answered How can a key be renamed in an Association?
Nov
3
comment How can a key be renamed in an Association?
The problem with this code is that it is O(n), where n is the number of keys, while it should better be O(1).
Nov
3
answered How can a field be efficiently added to a Dataset?