Leonid Shifrin
Reputation
80,178
288/100 score
 Feb 20 revised Mathematica Minecraft edited tags Feb 20 revised Patternmatching sets edited tags Feb 20 revised How to set Block local variables by code? edited tags Feb 20 revised Find the minima and maxima of a list edited tags Feb 20 comment Fastest way to test if a numerical array has complex elements @sebhofer I think mostly historical. There are a number of functions which reside in a "gray area", in the sense that they are widely used (also by internal code), yet not documented. But Return stands out since it is a public function, while most of those I meant are in Internal  , Developer  and such like. So, having it documented would be nice. Feb 20 awarded Nice Answer Feb 20 comment 3N-dimensional integral @acl Also, when I referred to the dimensional regularization, I only meant that many textbooks which cover it describe the generalized spherical coordinates in some detail. I did not mean to suggest actually using the regularization, since the integral is convergent. Feb 20 comment 3N-dimensional integral @acl I agree, I made a note on that myself, right below my first suggestion. I think this was just a reflex - I've done too many of those diagrams with dimensional regularization at the time (actually, I personally dislike it, because it is unphysical and regularizes both UV and IR, which is rather non-sensical given that UV and IR phenomena are often utterly different, except possibly for the case of anomalies. I prefer Pauli-Villars). But that's all in the past, now I am just a programmer, one of many. Feb 20 comment Find the minima and maxima of a list @whuber Re:code - I see. I did not read your post carefully, just saw the code, sorry :-). Re: APL - it is on my wish list, but Lisp/Scheme/Closure and ML/Ocaml are higher on the list (and so far I did not manage to move along that list to any significant extent either :)). Also, when I come to it, I may as well start with J or K or Q, rather than APL proper. Pipe dreams, all of it :-) Feb 19 comment Fastest way to test if a numerical array has complex elements @OleksandrR. A nice use of Return - this version did not occur to me here. Feb 19 comment Fastest way to test if a numerical array has complex elements But why not exit e.g. through exception throwing upon the first case where DeveloperPackedArrayQ[l, Complex] woul d give True`? It should be generally faster than either of the options you mentioned. Feb 19 comment Can I evaluate a notebook using Mathematica in text mode on remote machine? This question may be relevant. Feb 19 comment Find the minima and maxima of a list @whuber Darn, I just looked at the links - I swear I did not see your code! :-). It looks very elegant in R. I actually wanted to learn R better by re-implementing in it a bunch of my Mathematica solutions - now with RLink I can work from within Mathematica, and at the same time this will increase the test suite for RLink. But I've never had the time alas :). Returning to your R code, this leads me to the question - why didn't you recode that one in Mathematica and post it? Feb 19 comment Find the minima and maxima of a list @whuber I am by far not an R expert (it is actually funny how little one really needs to know about the language to write a basic link to it :-)), although from what I know I can see that in R this style will also be beneficial. But R surely took this vectorized paradigm from APL, or at least APL was AFAIK the first language to emphasize and embrace this paradigm (not that I know APL - I just know a little about it). As to the book, well, good to know, I am in good company :-) Feb 19 comment Find the minima and maxima of a list @whuber Apart from some value in itself, the actual reason I posted this answer is that this seems to be a good example of a not-too-trivial application of APL-style (vectorized) top-level coding. Sometimes I use SE as a way to document some of my things, since by posting an answer I can embed it into a wider SE context with cool answers of others, and I can easily reconstruct this full context just by finding my answer in my list of answers. A kind of a special way of bookmarking :-). Feb 19 comment Find the minima and maxima of a list @whuber Normally I don't care about vote counts too much, but they determine answers' visibility, and here I'd like to somehow let people know about the fact that, as long as efficiency is concerned, the current implementation of a built-in is not the best way to go (usually folks stop reading as soon as they see a short code based on a built-in). But I don't see a way of doing this without obvious self-promotion of this answer, and also the performance aspect was not emphasized in the question, so I guess we'll live with that until a specific performance-tuning question on this topic appears. Feb 19 comment Find the minima and maxima of a list @whuber Thanks. I have solved this problem a while back, originally for a new book I am slowly working on, where this is one of the performance-tuning / multiparadigm programming case study problems. I have compiled to C version which is a few times faster still, but it is also uglier. The real point here is that I beat the built-in 10 times - which speaks both in favor of my approach and not so well of the built-in code. I'll probably ask around about this, or at least let those who work on it know that that code is suboptimal, performance-wise. Feb 19 comment Thread a function over a list and with a non-atomic 2nd parameter? @alancalvitti Thanks for the accept. It's been a while :-). Feb 19 comment Find the minima and maxima of a list @YvesKlett I added a benchmark to my post. Feb 19 revised Find the minima and maxima of a list Added speed comparison with MinDetect