Skip to main content
16 events
when toggle format what by license comment
Aug 12, 2017 at 14:43 comment added Michael E2 BTW, DeleteCases[result, {_}] seems to be noticeably faster than Select[..]. And thanks again. :)
Apr 26, 2015 at 23:21 history bounty awarded ciao
Mar 16, 2013 at 14:32 comment added Leonid Shifrin @Mr.Wizard I second that. I knew about and used the "injector pattern" for a long time (albeit under a different name), but in this case I was so sure that the performance was going to be inferior, that I did not even think in this direction (which is strange in retrospect since I usually look for dualities like this, and even mentioned the element-position duality here (#8) - which is exactly the category where this particular technique belongs). So, what can I say - I wish I've thought of that :-)
Mar 16, 2013 at 4:15 comment added Mr.Wizard I realize that my comment above makes it sounds like I might have contemplated this specific form and dismissed it. That's not the case. What I mean is that I normally try to refactor code in the other direction, lumping data into one object that is then processed (as in decorate-and-sort) rather than dynamically accessing expressions on demand. Therefore I never even thought about this particular construct. I shall have to rethink my assumptions.
Mar 16, 2013 at 3:26 comment added Mr.Wizard Actually, it's not. I've never seen it before, and it didn't occur to me to try it, because for some reason it seemed semantically more complex even if syntactically simpler (so I figured it would be slower). In many cases the best ideas are simple in appearance. The "injector pattern" is very simple yet also very powerful. The step function I worked long to figure out has, IMHO, extensive implications for how we may handle expressions and definitions and is perhaps my best contribution to this site so far, yet it is a couple of lines of code. I give credit where it's due.
Mar 16, 2013 at 3:06 comment added Szabolcs @Mr.Wizard no need to give credit for something so small, I feel it's a natural approach
Mar 16, 2013 at 2:18 comment added Mr.Wizard Used, with credit, here: mathematica.stackexchange.com/a/21453/121
Mar 16, 2013 at 0:02 vote accept Michael E2
Mar 16, 2013 at 0:02 comment added Michael E2 Thanks. I did look at GatherBy. Gathering the positions somehow seems natural, but I didn't think of it.
Mar 15, 2013 at 16:42 history edited Szabolcs CC BY-SA 3.0
added 7 characters in body
Mar 15, 2013 at 16:34 history edited Szabolcs CC BY-SA 3.0
added 121 characters in body
Mar 15, 2013 at 12:01 comment added Mr.Wizard One thing: why not get rid of Module? positionDuplicates[list_] := GatherBy[Range @ Length @ list, list[[#]] &]
Mar 15, 2013 at 11:59 comment added Mr.Wizard Your method is faster than the standard decorate method I've been using: GatherBy[{#, Range@Length@#}\[Transpose], First][[All, All, 2]] &. One to add to the toolbox. Thanks!
Mar 15, 2013 at 6:53 comment added Sjoerd C. de Vries Smart. I don't think this can be beaten.
Mar 14, 2013 at 20:00 history edited Szabolcs CC BY-SA 3.0
added 117 characters in body
Mar 14, 2013 at 19:47 history answered Szabolcs CC BY-SA 3.0