Skip to main content
25 events
when toggle format what by license comment
May 15, 2015 at 7:59 vote accept Mr.Wizard
May 15, 2015 at 7:58 history edited Mr.Wizard
edited tags
Jul 16, 2014 at 12:02 comment added Jacob Akkerboom @Mr.Wizard I have updated my answer and I feel it is now quite complete. I did look a Szabolcs GatherBy inversion trick, but I think we cannot efficiently use it in the general case. The only thing that is missing now is to use your idea when level 1 and Heads-> False is specified, but I'd say that is a minor point.
Jul 14, 2014 at 20:45 answer added Taliesin Beynon timeline score: 30
May 23, 2013 at 3:57 answer added Michael E2 timeline score: 4
May 23, 2013 at 1:52 comment added amr There does occur to me a 'reason' for why there is no PositionFunction, and that is that Nearest and Interpolation are "subject matter" functions whereas Position is more a language thing. E.g. hypothetically, Nearest could be constructed from a variety of data structures because all that matters is the mathematical distance between one unit and another, whereas Position is entirely about the specific list structure you are using. Not saying I'd agree with this, but there is this conceptual difference which may have something to do with the absence of a PositionFunction.
May 22, 2013 at 13:04 answer added Simon Woods timeline score: 7
May 22, 2013 at 8:57 comment added user21 @Mr.Wizard, or if it's not listable pf /@ Range[10]
May 22, 2013 at 8:39 comment added user21 @Mr.Wizard, I think we are talking about the same thing: How about this: (* retruns a PositionFunction[data] which is listable *) pf = Position[a,levelSpec,n,opts]; pf[Range[10] (*pattern*)] { {{2}, {3}, {7}, {19}, {33}, {35}, {37}, {41}, {50}}, {{1}, {39}, {42}}, {}, ... }
May 22, 2013 at 7:56 comment added Mr.Wizard @ruebenko That is not the case I'm thinking of. The usual misuse is something like: a = RandomInteger[{1, 1000}, {5000}]; Table[{i, Position[a, i]}, {i, 1, 1000}] // Timing // First when magnitudes faster would be Sort[{#[[1, 1]], #[[All, 2]]} & /@ GatherBy[Transpose[{a, Range@Length@a}], First]] // Timing // First
May 22, 2013 at 7:50 comment added user21 @Mr.Wizard, +1, I think PositionFunction were (only) beneficial in the case were one has repeated position queries about the same input expr. The equivalent is certainly the case for NearestFunction and InterpolationFunction. What is a (strong) usage case for a PositionFunction that meets this criterion?
May 22, 2013 at 6:05 comment added Mr.Wizard @Leonid if you can spare the time I'd love to see you tackle this problem in earnest.
May 21, 2013 at 17:56 answer added Jacob Akkerboom timeline score: 7
May 21, 2013 at 17:07 history tweeted twitter.com/#!/StackMma/status/336891117591228416
May 21, 2013 at 14:37 comment added Leonid Shifrin In this answer, I described some implementation techniques which may also be applicable here.
May 21, 2013 at 13:56 comment added rcollyer I find it funny that I really only started to use Position after participating here. I think this site has warped my sensibilities. :D
May 21, 2013 at 13:45 history edited Mr.Wizard CC BY-SA 3.0
deleted 36 characters in body
May 21, 2013 at 13:36 comment added Mr.Wizard @RodLm Yes, I think Position is commonly used by many people, and many of its applications are good. I don't mean to imply that Position itself is slow, only a certain use where it is used repetitively. I want to make sure that is clear.
May 21, 2013 at 13:32 comment added Rod I can speak for myself, as I have several notebooks where I use Position. So, I believe Position is used more often than you think by the vast majority of users (not only unexperienced ones)...
May 21, 2013 at 13:29 comment added Mr.Wizard @RodLm -- Thanks! You're getting ahead of the issue as I hope this questions helps establish whether such a function is even practical.
May 21, 2013 at 13:27 comment added Rod BTW, congrats for the 60K ! Is there any way to "suggest" this function in the next version of Mathematica?
May 21, 2013 at 13:26 comment added Mr.Wizard @RodLm I'm not sure how to read that; often Position is well used too, and I certainly use it a lot myself (not implying that makes it right). Rather, certain uses of it are quite slow. I hope to bring attention to the issue and perhaps develop a useable general function.
May 21, 2013 at 13:23 comment added Rod I belong to the team of Position[]-users... :-(
S May 21, 2013 at 13:16 answer added Mr.Wizard timeline score: 14
S May 21, 2013 at 13:16 history asked Mr.Wizard CC BY-SA 3.0