GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing reference.wolfram.com — Position: Find where specified objects appear in an expression—Wolfram Documentation Details and Options
Examples
Basic Examples
Scope
Options
Heads
Properties & Relations
Possible Issues
See Also
Tech Notes
Related Guides
Related Links
History
Cite this Page
PositionDetails and Options
Examplesopen all close allBasic Examples (3)Find the positions at which b occurs: Position[{a, b, a, a, b, c, b}, b]Position[{{a, a, b}, {b, a, a}, {a, b, a}}, b]Find all positions at which x to any power appears: Position[{1 + x ^ 2, 5, x ^ 4, a + (1 + x ^ 2) ^ 2}, x ^ _]Find only those down to level 2: Position[{1 + x ^ 2, 5, x ^ 4, a + (1 + x ^ 2) ^ 2}, x ^ _, 2]Find positions with prime values in an association: Position[<|"a" -> 1, "b" -> 2, "c" -> 3, "d" -> 4|>, _Integer ? PrimeQ]Scope (5)Find the positions of the first 2 b's that appear on level 1: Position[{a, b, a, a, b, c, b, a, b}, b, 1, 2]Use a position operator: op = Position[_Integer]op[{1, 1, f[a], 2, 3, y, f[8], 9, f[10]}]Get the positions of entries in a matrix that are symbols: Position[{{a, 2}, {3, d}}, _Symbol, {2}, Heads -> False]Without HeadsFalse, the positions of the head List in each row would also be returned: Position[{{a, 2}, {3, d}}, _Symbol, {2}]Extract[{{a, 2}, {3, d}}, %]Find positions inside an Association: Position[<|{1 -> 1 + x ^ 2, 2 -> <|"a" -> x ^ 2|>, 3 -> x ^ 4, 4 -> a + (1 + x ^ 2) ^ 2}|>, x ^ _]Position works with any head: Position[f[a, b, b, a], b]Options (1)Properties & Relations (6)Use Extract to extract parts based on results from Position: u = {1 + x^2, 5, x^4, a + (1 + x^2)^2};Position[u, x ^ _]Extract[u, %]Position[expr,expr] returns {{}}, a list containing position {}, that means the whole expression: Position[x, x]This returns an empty list of positions, because y was found nowhere in x: Position[x, y]Depth-first traversal gives longer lists of indices first: Position[f[g[h[x]]], _, Infinity]The keys of an association are not matched by Position: Position[<|"a" -> {1, b}|>, "a"]However, keys are used to return positions inside of associations: Position[<|"a" -> {1, b}|>, _]Position[p][e] is equivalent to Position[e,p]: Position[_][{a, b}] === Position[{a, b}, _]Count returns the length of the result given by Position: Length[Position[{1, "f", g, "h", "7"}, _ ? StringQ]]Count[{1, "f", g, "h", "7"}, _ ? StringQ]Possible Issues (1)See AlsoFirstPosition Cases Count SequencePosition StringPosition PositionLargest PositionSmallest PositionIndex LengthWhile Ordering SparseArray ReplaceList Insert Delete ArrayRules Extract Function Repository: PositionedCases SelectPositions PositionQ SubexpressionPositions ToExplicitPosition SelectIndices HistoryIntroduced in 1988 (1.0) | Updated in 2014 (10.0)
Wolfram Research (1988), Position, Wolfram Language function, https://reference.wolfram.com/language/ref/Position.html (updated 2014).
TextWolfram Research (1988), Position, Wolfram Language function, https://reference.wolfram.com/language/ref/Position.html (updated 2014). CMSWolfram Language. 1988. "Position." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Position.html. APAWolfram Language. (1988). Position. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Position.html BibTeX@misc{reference.wolfram_2026_position, author="Wolfram Research", title="{Position}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Position.html}", note=[Accessed: 12-November-2026]} BibLaTeX@online{reference.wolfram_2026_position, organization={Wolfram Research}, title={Position}, year={2014}, url={https://reference.wolfram.com/language/ref/Position.html}, note=[Accessed: 12-November-2026]} | ||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |