Reputation
Next tag badge:
209/100 score
19/20 answers
Badges
6 195 286
Newest
 Nice Answer
Impact
~419k people reached

May
19
comment What's the goal of the Macros` package?
+1. I would add to this that Lisp-style macros are not possible without introducing a separate "read-time", that is, a stage where code has been read (or is being read), but not yet executed, and where one could attach some hooks. In fact, my project on fine-grained modules was meant to provide such read-time (among other things), and I was particularly having in mind Lisp-style macro support. Hopefully, I will move that along some time soon.
May
16
awarded  Nice Answer
May
14
comment Computing large nested values
I tried 2*10^9, and it works just fine. The time to get the result seems to grow linearly with n. Since the computation is done with machine precision, I don't see any issues increasing n further, except the trivial one that it takes proportionally longer to compute.
May
14
comment Only `Break` from innermost loop
Another advantage of the method I proposed is that it won't be too hard to get it into Compile, if needed.
May
14
comment Only `Break` from innermost loop
@MariusLadegårdMeyer Indeed, it works, although it's not obvious at all that it should. I can well imagine an implementation of Do[body, iter1, ..., itern], which would satisfy all the Do specs but where this won't work. So, unless I am missing something, this means relying on hidden deatails or an implementation (which one also often does, but which is generally considered not to be a great practice).
May
14
revised Only `Break` from innermost loop
Corrected per MichaelE2 comment
May
14
comment Only `Break` from innermost loop
@MichaelE2 You are right, nicely spotted! Will edit.
May
14
answered Only `Break` from innermost loop
May
11
comment in the part assignment is not a symbol, create different matrices with a “Do” loop
I have made some suggestions in my answer to the linked question.
May
11
comment in the part assignment is not a symbol, create different matrices with a “Do” loop
The l.h.s. of your assignements, like Ma[1], are what usually is called indexed variables in Mathematica. You can't make part assignment to them, or any other expressions, other than symbols (atomic expressions with head Symbol, such as Ma). The reason for that is that Part, and particularly part assigment, is a lower-level operation than most. In most other operations, one can use indexed variables just like one would use Symbols. Have a look here.
May
8
comment Functions vs. patterns
@JacobAkkerboom Well, but this relies on a global variable. So, in my book this doesn't count, I think. Will revisit this later, right now this is just my first impression.
May
8
comment Understanding HoldSequence and ReleaseHoldSequence in Error Handling
Well, this is just a way to process errors. Since Which is evaluated right away, the fact that it reached tha part wrapped in HoldSequence means that there are no errors in the input. The $FailRHS symbol is used to separate the error - reporting logic (issue messages etc) at the top from the actual decision for the rule to match or not match, at the bottom. There are many ways to do this, this is just one of them.
May
8
comment Why aren't parentheses ( ) an expression in Mathematica?
@LLlAMnYP Replacement rules work, because parsing a string to an expression is a two-step process. The string input is first parsed to boxes, which are expressions representing the a lower-level structure that preserves the punctuation (parentheses, things like infix and postfix forms, etc). If you intersept it at that level, you can change how expression will be parsed at the end. This is what was done in that answer you referred to.
May
8
comment Why aren't parentheses ( ) an expression in Mathematica?
@LLlAMnYP "In this sense parentheses by themselves are not an expression, but they do affect how input is parsed (or converted to the FullForm, if you will)." - what is being parsed is not yet an expression - it is either a string or a box form. At the point when we start speaking of expressions, parentheses don't exist any more. FullForm merely shows how expressions are represented internally, but they are parsed to internal representation in any case, with or without FullForm in code. It's just that, there is nothing more to it.
May
8
comment What makes items with head `Function` different?
In your place, I'd read Chapter 7 on evaluation process in David Wagner's book "Power programming in Mathematica" - available for free here on the site for download - this should clarify a lot of issues. The Function construct is special, and has a special evaluation semantics, which is why you see the difference. Also, read this.
May
8
comment Functions vs. patterns
@kirma In any case, I am very interested in this topic, and particularly the one you mentioned. Just hope I will get some good chunk of free time rather soon, and will be able to dig deeper into this.
May
8
comment Functions vs. patterns
@kirma And I am interested. At some point long ago, as my first project at WRI, I wrote a simplistic interpreter / compiler from a subset of Matlab to Mathematica. I can now tell that much, because that project is likely to be open-sourced some time soon. Compiler was generated from interpreter, using partial evaluation. I think this is somewhat similar in spirit to what PyPy does. Anyway, I'd be very happy to dig deeper into PyPy, but so far just didn't have the time for that.
May
8
comment Functions vs. patterns
@Mr.Wizard Well, that's not really a proper way to do that. Perhaps, I should have put it differently. But that hack based on Stack isn't something I'd put into production code.
May
8
comment Why aren't parentheses ( ) an expression in Mathematica?
Parentheses are used for parsing, to change the relative priorities of parts. Expressions are a result of parsing. So, parentheses simply can't survive the parsing stage, being consumed and thrown away then. It's like asking, why there is no milk in а butter.
May
8
revised Functions vs. patterns
added 317 characters in body