Reputation
70,508
Next tag badge:
215/100 score
20/20 answers
Badges
7 212 301
Impact
~449k people reached

2h
revised Monitor the computation only if a certain Option is given to the function
Ditched the verbose version
2h
comment What kind of creature is h[c] for definition h[c_][x_] := (* function of x and c *)
@murray One useful thing here is to think how would you alternatively implement such a construct. If you want it to have exactly the same semantics, you can do something like h[c_]:=Function[x, (x + c/x)/2]. This reveals that you create a closure, closed over the value of c. So, this is one way to think also about h[c][x] construct when defined with rules, from the functional programming (operational) viewpoint - although the mechanism is technically very different.
2h
comment What kind of creature is h[c] for definition h[c_][x_] := (* function of x and c *)
It is simply an expression which by itself does not get rewritten non-trivially, so stays inert. It is not different from any other expression that doesn't have global rewrite rules applicable to it. You can make it behave as a function, however. Technically, this is realized via SubValues. This allows you to pass the "arguments" collected in h (like 2 in this case), to the body of the "function" (r.h.s. of the rule). This is useful, since it allows you to separate parameters which are fixed externally (behaves like constants, 2 here), from those which are passed dynamically.
2h
comment Monitor the computation only if a certain Option is given to the function
@MarcoB Thanks! Glad you liked it. I hesitated a bit to post it, since I am not fully convinced that the issue with leaking of local symbols can be always easily avoided. But objectively, the general formulation of the problem requires state - sharing by more than one function, so there is no way to avoid this issue in the general formulation of this problem. The problem caught my eye also because I do need similar things myself.
3h
answered Monitor the computation only if a certain Option is given to the function
3h
awarded  string-manipulation
4h
awarded  Enlightened
5h
awarded  Nice Answer
5h
awarded  Great Answer
6h
awarded  Nice Answer
21h
revised How to specify that Quiet should silence foo::shdw messages for ANY symbol foo?
Added a few extra bits and examples
22h
answered How to specify that Quiet should silence foo::shdw messages for ANY symbol foo?
1d
comment How to specify that Quiet should silence foo::shdw messages for ANY symbol foo?
Can't you just avoid the shadowing? The shadowing issues typically indicate the problems with design of the code, and can be avoided. OTOH, these problems, if not taken care of, can lead to pretty nasty surprises, so I'd hesitate to just silence them.
1d
comment Splitting a list into increasing sublists
@ciao As much as I'd like to solve this puzzle, I can't afford taking any more time from other things I need to take care of, at the moment. I did actually look at the accumulated original list before asking you, but I guess my pattern-recognition skills got seriously worse in the few last years. But the one thing that really stopped me from looking in that direction initially was that we can't exclude negative elements in the list, in which case accumulated list will not be necessarily sorted, and so binary search can't be used. But I see the direction of thought.
1d
comment Splitting a list into increasing sublists
@ciao You got me intrigued - how would you apply a binary search to this problem?
1d
comment Splitting a list into increasing sublists
@ciao This is not an error per se. The initial value of the sum, which the sum of elements in the first sublist of the result must be larger than, has not been specified by the OP. I took it to be zero. In this interpretation, the answer is right. Alternatative interpretation is that it it e.g. -Infinity (or, simply, any number smaller than the first element). The problem is simply underspecified in this respect.
1d
comment No names when loading package
Ok, I missed the point. Given that you work within nb, link given by @ilian is most relevant. But, is there any reason you don't just use any text editor to save this contents to a file? It seems a much simpler way to me.
1d
comment No names when loading package
So, does the correct command give you the function names all right?
1d
comment No names when loading package
You quoted Names["SOPackages`*"], while it should've been Names["SOPackage`*"]. Could it be just a simple typo?
1d
comment Large lists to manipulate later in chunks
@martin Sure. It may get closed by then, though, and if it does, it will be best to completely reformulate the question and ask it again. Alternatively, you may ping the closers or mods, or anyone in chat, and ask to reopen the original question. Even if it does not get closed, it might be better to delete it and ask a fresh one. The advantage of asking a new question is that new questions attract more attention - it is hard to get attention to an update to the old question, typically. Just make sure that the new version is better formulated.