Timeline for Finding the first position in a list that is over a certain value
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 4, 2014 at 19:50 | comment | added | ubpdqn | @Artes agree my answer naive and I do not explore in any meaningful way inputs...just curious after a long day at work in antipodes... | |
Nov 4, 2014 at 14:54 | comment | added | Artes |
@AlexeyPopkov He's chosen RandomInteger[{-10, 10}, n] i.e. as a list it is of length $n$ (it may be whatever you want) but there are only $21$ different elements. If you played with e.g. long lists of primes with special properties and you were to choose a very special number then FirstPosition should be much better. I have no time to provide appropriate tests but I guess now it should be clear what I mean. I believe you can find a good example otherwise I'll try tomorow.
|
|
Nov 4, 2014 at 14:41 | comment | added | Alexey Popkov |
@Artes I'm not familiar with the notation $21$. What does it mean? Could you give an example where FisrtPosition has better performance than other methods?
|
|
Nov 4, 2014 at 14:33 | comment | added | Artes |
@AlexeyPopkov As you might observe random long lists out of a $21$-element set is very special choice which obviously rewards methods based on NestWhile or While . So it should be quite simple to point out different data where FirstPosition is much better even for long lists. This is what I meant in my former comment.
|
|
Nov 4, 2014 at 14:05 | comment | added | Alexey Popkov | @Artes Currently for WRI the verbosity of the language is an argument for introducing new functions. In the view of this fact the comparisons like in this answer become especially valuable. | |
Nov 4, 2014 at 13:15 | comment | added | Artes |
While this comparison is interesting I don't believe it represents a correct picture of relative efficiency. Do you really belive that NestWhile or While are more efficient than FirstPosition ? I guess it is just an artefact of very special data you work with. In more general situation FirstPosition should be definitely faster, otherwise I can't see any argument for introducing this function to the system.
|
|
Nov 4, 2014 at 12:01 | history | answered | ubpdqn | CC BY-SA 3.0 |