Wolfram: List. Change Element
Replace Parts by Position
ReplacePart-
Replace parts by Position .
(* replace second element by x *) ReplacePart[ {a, b, c}, 2 -> x ] (* {a, x, c} *) (* replace second element by x *) ReplacePart[ {a, {3, 4}, c}, 2 -> x ] (* {a, x, c} *) (* replace multiple positions *) ReplacePart[ {a, b, c, d}, {2 -> x, 3 -> y} ] (* {a, x, y, d} *) (* replace element at position {2,1} by x *) ReplacePart[ {a, {3, 4}, c}, {2,1} -> x ] (* {a, {x, 4}, c} *)
Replace Parts of a Expression in Variable, by Assignment to an Index
if the expression is assigned to a variable, you can also modify a element by assignment.
var[[n]] = val-
Assign a new value at index n in var. Note,
expr[[n]]is shortcut forPartxx = {a, b, c}; xx[[2]] = 4; xx (* {a, 4, c} *)
Replace Parts by Pattern
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