59,107 reputation
6176266
bio website mathprogramming-intro.org
location St. Petersburg, Russia
age 38
visits member for 2 years, 9 months
seen 8 hours ago

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


Oct
18
comment DownValue assignment using Apply
+1. I think I will point to a similar discussion I had in my post answering this question.
Oct
17
comment Detect Messages within an expression without losing the return value?
@becko See my edit.
Oct
17
revised Detect Messages within an expression without losing the return value?
Added an alternative version to address the request in comments
Oct
17
comment Detect Messages within an expression without losing the return value?
@becko I think, this spec is underdesigned. What if more than one message is generated during the evaluation? Do you want to evaluate expr2 on every generated message? Also, you will probably need to somehow pass the information about the currently generated message to the expr2. One way of doing this would be to use the syntax withMessageDetection[expr1, {msginfo_Symbol,expr2}], where you refer to whatever symbol you pass as msginfo, inside expr2, if you need that. Another way would be to make expr2 a function of those message parameters. Let me know which you'd prefer.
Oct
17
answered Detect Messages within an expression without losing the return value?
Oct
17
comment Association and rudimentary object-oriented programming
I have discussed this topic a bit in my post on the use of Associations, and also here (not in the context of Associations). I you search this site, and also Wolfram Mathematica tag on Stack Overflow, you will find many more OO-related discussions.
Oct
16
comment How to write complex function definitions at run time?
@Mr.Wizard I saw this question the moment it was asked. Unfortunately, I don't have the time at the moment for anything more than a few comments. But, chances are that I wouldn't produce a better answer here than you did. If I had the time, I'd try to address a problem more generally, but that would require a lot more time than I currently have.
Oct
16
comment How to write complex function definitions at run time?
The new constructs you mentioned are really not in the same league as macros in CL, simply because in Mathematica there is no read time (at least not in the sense in which it is present in CL), and everything is happening at run-time. Therefore, you can't safely assume that the code (except macros) is truly inert, and so far I haven't seen a compelling case where the new constructs would significantly alleviate the pain of evaluation control.
Oct
16
comment How to Use Mathematica as a C/C++ compiler
@halirutan I certainly meant the second one, but somehow I think the answer is the same regardless :)
Oct
16
comment How to Use Mathematica as a C/C++ compiler
@halirutan But will that work if they buy a mining truck instead?
Oct
16
comment How to Use Mathematica as a C/C++ compiler
This is the most weird request I've encountered in a very long time. If you want to learn C, learn how to use the C compiler.
Oct
15
comment Automating constructor definitions (OptionValue eval time)?
I actually think this is a dupe of that link, so I'd better vote to close. It's probably still worth to keep this question, perhaps the title could be changed a bit to reflect that the actual problem is in OptionValue.
Oct
15
comment Automating constructor definitions (OptionValue eval time)?
Ok, here it is. Not sure whether or not your question is a dupe of that, would need to study it closer to tell.
Oct
15
comment Automating constructor definitions (OptionValue eval time)?
Don't have much time to test now, but it should work when you change OptionValue to (OptionValue[#]&), and has indeed to do with how / when OptionValue is evaluated. There has been a discussion on that, I will try to find a link.
Oct
13
awarded  Enlightened
Oct
13
comment DownValue assignment using Apply
Set holds its first argument, so you need to force the evaluation inside Set. To work in all cases (including the case when a has been already defined on that index), I'd do something like Hold@@index/.Hold[inds__]:>Set[a[inds],5]. This seems to be a duplicate of at least one similar question, but I can't find it.
Oct
13
awarded  Nice Answer
Oct
13
awarded  Enlightened
Oct
13
awarded  Nice Answer
Oct
13
awarded  Good Answer