57,752 reputation
5164256
bio website mathprogramming-intro.org
location St. Petersburg, Russia
age 38
visits member for 2 years, 8 months
seen 11 hours ago

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


Aug
20
comment What is the fastest way to count square-free words?
+1, very nice use of string patterns.
Aug
20
revised find subsequences of constant increase
edited tags
Aug
20
answered find subsequences of constant increase
Aug
19
comment Implementation of builtin function Fold
You are welcome :) I did not wish do diminish your code at all. But this is a first time I see such a "well-hidden" recursion, so I thought it would be useful to add a comment on its existence and dangers. Also, generally, I think that when we consider emulations of some built-in functions, it is always good to spell out all the differences. This both helps to understand the function in question better, and the limitations of the emulated version.
Aug
19
comment Recovering intermediate results from a Table after an interruption
@chris No problem at all. I just meant to say that it pays off to not consider functions as black boxes in cases when their behavior is unclear, particularly when their implementations are somehow available - this way, you have to memorize much less.
Aug
19
comment Map efficiently over duplicates in list
Keep in mind that both memoization or other hash-based approaches (rules, Dispatch, etc) may actually make things slower for numerical lists when your function is compilable, since Map auto-compiles and switching to memoization etc you will lose that advantage (not to detract from the suggestions to use memoization etc, since those are the right things to do generically).
Aug
19
comment Implementation of builtin function Fold
This implementation is nice conceptually, but has a serious flaw of not being tail-recursive. But, due to its clever scheme of first generating the expression in full and then evaluating, you fool the system so that it only requests to change the $IterationLimit (you basically construct a full but unevaluated call stack at once). The recursion is of course still there however, and when I try, e.g., Block[{$IterationLimit = Infinity}, myFold[Drop, Range[100000], ConstantArray[1, {100000}]]], this silently blows the stack and crashes the kernel on my machine.
Aug
19
comment Recovering intermediate results from a Table after an interruption
@chris Yes, I would. You should have inspected an implementation of ShowPorgress more closely, which would have revealed to you that ShowProgress has special cases targeteed specifically at Table. Since abortableTable is a different head, it is serviced by a fall-back definition, hence the difference. Replacing everywhere in ShowPorgress Table with abortableTable (or adding new such definitions for abortableTable to ShowProgress) would remove the discrepancy.
Aug
17
comment How do I create and use Mathematica packages?
+1. Accessing private symbols is often very handy for debugging (to me at least). Generally, I find the namespace / package system in Mathematica very well designed (to the point that I don't recall any flaws off the top of my head, for all the time I was using it), and also very hackable, since one can do a lot of non-standard tricks which allow for very flexible manipulations with namespaces. A more closed namespace model would rule out such uses, making encapsulation mechanism significantly less powerful.
Aug
17
comment How do I create and use Mathematica packages?
@R.M The problem is that either way, there should have been some error message generated, since with the space, that line is a syntax error, and if the file wasn't found, then Get should have complained.
Aug
17
comment How do I create and use Mathematica packages?
Try also Names["TestPackage`*"] - you should get {"TestPackagef"}` or simply {"f"} if the package has been loaded.
Aug
17
comment How do I create and use Mathematica packages?
Take a look here and here - this may get you started. To test your package, place it in $UserBaseDirectory/Applications, at least temporarily. I suspect that you don't really load it.
Aug
17
comment Lazy lists of Tuples and Subsets
One of the questions I would ask myself first is whether you consider your lists (which you want to iterate over) as proper lists (ordered sets) - in which case the order of iteration matters, or unordered (proper) sets, in which case you simply need an iterator which would iterate through the set without a specific prescribed order (if this is the case, then insisting on the element-by-element positional correspondence to functions such as Subsets, which return entire collection at once, may be too strong a requirement).
Aug
17
comment Integro-differential equation
What I would try to do is to first remove the second derivative under the integral by integrating by parts twice, and then integrate your equation over time numerically iteratively, discretizing the time variable and computing the value of y(t+dt) from y(t) using your equation (its r.h.s) with y(t,x) obtained at the previous step. I actually used similar methods with success in the past, also in Mathematica.
Aug
15
comment Strange results while nesting scope constructs?
@Reb.Cabin Thanks, good to know. Thanks also for the accept.
Aug
14
comment Evaluation of self-defined functions
A general remark is that defining functions which implicitly depend on global variables is, for most cases, a recipe for disaster. It may be also the case for your function. Check this answer for more details.
Aug
14
comment Strange results while nesting scope constructs?
@Rojo Thanks, but I think you were essentially saying the same, I just went into somewhat greater detail.
Aug
14
comment Strange results while nesting scope constructs?
+1, brief and to the point.
Aug
14
comment Strange results while nesting scope constructs?
@Rojo I think you shouldn't, I just finished reading it and you said in a shorter way many of the things I tried to explain here.
Aug
14
answered Strange results while nesting scope constructs?