Find the index of the minimal element using Mathematica ...
yuluyan.com › posts › mma-min-indexNov 06, 2020 · This post was auto converted and may contain formatting errors. It occurred to me that I needed to find the minimal element (if there are multiple occurences, just return any one of them), as well as its position, in a list using mathematica. This seems to be a trivial problem and the easiest (but not the most efficient) way that came to the top of my head is the following one-liner code:
Position—Wolfram Language Documentation
reference.wolfram.com › language › refPosition [expr, pattern] tests all the subparts of expr in turn to try and find ones that match pattern. Position returns a list of positions in a form suitable for use in Extract, ReplacePart, and MapAt. The form is different from the one used in Part. Position looks only for matches to values in Association objects that appear in expr.
Find the largest element in a list and its position? - Online ...
community.wolfram.com › groups › -findLargest1 [list_List] := Module [ {max, poss}, (* Find largest element in list *) {max} = TakeLargest [list, 1]; (* Find all positions of largest element in list *) poss = Flatten [Position [list, max]]; (* Return *) {max, poss} ] absTime = AbsoluteTime []; {max, poss} = findLargest1 [list]; absTime = AbsoluteTime [] - absTime; show [absTime, max, poss, findLargest1, "TakeLargest & Position", list]; findLargest1 (TakeLargest & Position): 0.923 sek.
Position—Wolfram Language Documentation
https://reference.wolfram.com/language/ref/Position.htmlPosition[expr, pattern] gives a list of the positions at which objects matching pattern appear in expr. Position[expr, pattern, levelspec] finds only objects that appear on levels specified by levelspec. Position[expr, pattern, levelspec, n] gives the positions of the first n objects found. Position[pattern] represents an operator form of Position that can be applied to an expression.
Finding the index of a specific element in a list - Mathematica ...
https://mathematica.stackexchange.com › ...Given data = {280., 280.5, 281., 281.5, 282., 282.5, 283., 283.5, 284., 284.5};. you could use data[[;; Position[data, 282.][[1, 1]]]].