Reputation
69,093
Next tag badge:
211/100 score
19/20 answers
Badges
6 204 294
Newest
 Good Answer
Impact
~446k people reached

Mar
5
comment A Faster way to combine two Lists of different structures into one of a different structure
@RunnyKine Did you see my comment? I suggested an improvement on Rojo's code, and it is that improved version that, at least on my machine, is about 4 times faster than the original one, and twice faster than Artes's version, for large lists. I tested for the length 10^5 and 10^6. Heuristically, it seems that the reason my version is twice faster is that it has only one Transpose operation.
Mar
5
comment A Faster way to combine two Lists of different structures into one of a different structure
Good one, +1. See my comment on @Rojo's code, where I suggest an improvement, which makes it about twice faster than yours.
Mar
5
comment A Faster way to combine two Lists of different structures into one of a different structure
@Rojo Nice one, very fast. The bottleneck in your code is in List /@ .... This version will be considerably faster still: Join[lis1, Transpose[{lis2}], 2].
Mar
5
comment How does the built-in debugger decide what to highlight?
@Szabolcs I think that we have not yet explored all the possibilities that Mathematica meta-programming gives us in this respect. I would agree that some kind of debugger would be very useful, I am just not sure that the current built-in one is the one I would choose. I did not yet invest enough time into this (there is an alternative debugger by David Bailey, perhaps some other useful tools exist and /or can be created), but I also feel that there can be something very useful that we are missing here.
Mar
5
comment How does the built-in debugger decide what to highlight?
So, the "functional debugger" would rather be a device which would trim the larger structures we actually work on to some smaller sizes, appropriate for inspection. This is hard to automate. Therefore, debugging of well-written functional programs normally would consist of code dissection and inspection of the data transformation steps, which usually can be taken out of the context and tested by themselves (due to immutability). So, for functional code, a big part of debugging actually happens right when we write the code, since the better it is written, the easier it is to debug it.
Mar
5
comment How does the built-in debugger decide what to highlight?
I think that there is a bigger problem here. Imperative languages are statement-based, and tend to work by breaking things into small pieces (such as array elements) and working on them separately. This makes it easy and natural to inspect those, and monitor the execution step by step. Functional languages are doing something else typically: they are optimized to work on trees of various sorts. Inspecting the steps here would very often involve the inspection of rather large structures at every step, and it is this issue IMO which makes the conventional debugging harder here.
Mar
5
awarded  Good Answer
Mar
5
comment Why does compiling a function with ConstantArray give an error when used in parallel?
ConstantArray is not compilable, even though this is not very apparent from looking at the instructions (f[[6]]), but it can be seen with CompilePrint - there is a callback to MainEvaluate. This is what the message warns about. Use Table to get the fully compiled code.
Mar
5
comment How is the Mathematica kernel structured internally, and how does evaluation work?
This question may also be (somewhat) relevant.
Mar
5
comment How does MakeBoxes handle an n-ary operator?
@RandomBits In other words, List @@ Replace[ HoldComplete[x], elem_ :> MakeBoxes[elem, form], {1}] should work just as well here, while being less magical.
Mar
5
comment How does MakeBoxes handle an n-ary operator?
@RandomBits I should have given more explanations. I need to pass each of the arguments of the x sequence to MakeBoxes. I use HoldComplete to avoid their premature evaluation. To evaluate them inside HoldComplete, I use Trott-Strzebonski technique. This is actually an overkill here, I could have just used elem_ :> MakeBoxes[elem, form], and then all these would evaluate at the point when HoldComplete head is changed into List.
Mar
5
comment How does MakeBoxes handle an n-ary operator?
@RandomBits Glad I could help. See also my update on evaluation leaks and the second version. Thanks for the accept. B.t.w., typically it is better to wait for a while before accepting an answer, to encourage others to contribute more answers. You can also accept a different answer at any time later.
Mar
5
revised How does MakeBoxes handle an n-ary operator?
Added a version which does not leak evaluation
Mar
4
answered How does MakeBoxes handle an n-ary operator?
Mar
4
revised How to find the name of the current function
Fixed a renaming issue with deflex
Mar
4
comment How to find the name of the current function
@sebhofer The best I can tell at the moment is what is described in my answer to this question.
Mar
4
revised How to find the name of the current function
Added a warning on the limitations of this approach
Mar
4
answered How to find the name of the current function
Mar
2
comment How can I get Google search results with Mathematica?
Have a look at this answer. Presumably, Google expects you to switch to a newer API.
Mar
2
answered Parallelization of REvaluate[]?