Wolfram: List. Get Parts
Get Item by Position
Get Item by Index
Get a Single Item by Index
Part[expr, i]-
🔸 SHORT SYNTAX:
expr[[i]]ith part of expr. If i is negative, count from right.
Part[{a, b, c, {d1, d2}, e}, 2] (* b *) (* short syntax *) {a, b, c, {d1, d2}, e}[[2]] (* b *) (* count from right *) {a, b, c, {d1, d2}, e}[[-2]] (* {d1, d2} *)
Get Multiple Items by Index
Part[expr, {a, b, c}]-
🔸 SHORT SYNTAX:
expr[[{a, b, c}]]Same as
{ Part[expr, a], Part[expr, b], Part[expr, c] }{a, b, c, {d1, d2}, e}[[{2,-1}]] (* {b, e} *)
Get Nested Item by Indexes
Part[expr, a, b, c]-
🔸 SHORT SYNTAX:
expr[[a, b, c]]same as
Part[Part[Part[expr, a], b], c]{a, b, c, {d1, d2}, e}[[4,1]] (* d1 *)
Get a range of Items by Index Range
Part[expr, m;;n]-
🔸 SHORT SYNTAX:
expr[[m;;n]](note:
a;;bis short forSpan[a, b])parts m through n. If m is omitted, default to beginning. If n is omitted, default to end.
{a, b, c, {d1, d2}, e}[[2;;4]] (* {b, c, {d1, d2}} *) expr[[m;;]]→ part m to endexpr[[;;n]]→ beginning to nexpr[[;;,j]]→ column jexpr[[m1;;n1, m2;;n2]]→ submatrix
(* column 1 *) {{a,b}, {c,d}}[[;;,1]] (* {a, c} *)
Get Items by Range of Index
Take-
take nth to mth item
(* basic examples of Take *) (* First 3 *) Take[{1, 2, 3, 4, 5, 6, 7, 8, 9}, 3] (* {1, 2, 3} *) (* last 3 *) Take[{1, 2, 3, 4, 5, 6, 7, 8, 9},-3] (* {7, 8, 9} *) (* m to n *) Take[{1, 2, 3, 4, 5, 6, 7, 8, 9}, {3,5}] (* {3, 4, 5} *) Drop-
Return a list with nth to mth dropped
Other List Extraction by Index Functions
Wolfram. List Operations, and Loop, Iteration, Recursion
- Wolfram: List Operations
- Wolfram: List. Create (Table)
- Wolfram: Create Flat List (Range)
- Wolfram: List. Get Parts
- Wolfram: List. Add Element
- Wolfram: List. Delete Element
- Wolfram: List. Change Element
- Wolfram: List. Check Exist
- Wolfram: List. Join, Union, Intersection, Difference
- Wolfram: List. Min, Max
- Wolfram: List. Filter
- Wolfram: List. Sort Reverse Ordering
- Wolfram: Flatten
- Wolfram: Riffle (Add at Every Nth)
- Wolfram: RotateLeft
- Wolfram: Padding
- Wolfram: List. Partition, Reshape, Split, Gather
- Wolfram: Transpose
- Wolfram: List. Same Items Counts, Tally, Group
- Wolfram: List. Combinatorics
- Wolfram: Iteration
- Wolfram: Map Function to List
- Wolfram: Scan (foreach)
- Wolfram: Recursion
- Wolfram: Fold (reduce)
- Wolfram: Loop