Wolfram: List. Delete Element
Delete by Index or Index Range
These are useful when the expression is considered as a flat list.
Delete N Items from Beginning or End
Drop[ expr, n]-
- Delete n items from beginning.
- If n is negative, delete from end.
Drop[ {1, 2, 3, 4, 5}, 2 ] (* {3, 4, 5} *) Drop[ {1, 2, 3, 4, 5}, -2 ] (* {1, 2, 3} *)
Delete Nth Item
Drop[ expr, {n}]-
delete nth item.
Drop[ {1, 2, 3, 4, 5}, {3} ] (* {1, 2, 4, 5} *)
Delete Multiple Consecutive Items by Index Range
Drop[ expr, {m, n}]-
delete mth to nth.
Drop[ {1, 2, 3, 4, 5}, {2,4} ] (* {1, 5} *)
Delete Items by Position Spec
These are useful when the expression is considered as a nested list. You want to delete some nested part of the expression.
Delete One Item by Position
Delete[expr, pos]-
delete the item at Position pos
Delete[ {a, {{b, c}, d}, e}, {1} ] (* {{{b, c}, d}, e} *) Delete[ {a, {{b, c}, d}, e}, {2} ] (* {a, e} *) Delete[ {a, {{b, c}, d}, e}, {3} ] (* {a, {{b, c}, d}} *) (* HHHH------------------------------ *) Delete[ {a, {{b, c}, d}, e}, {-1} ] (* {a, {{b, c}, d}} *)
Delete[expr, n]-
shortcut for
Delete[expr, {n}]same as delete element at nth index.
Delete[ {a, {{b, c}, d}, e}, 1 ] (* {{{b, c}, d}, e} *) (* same as *) Delete[ {a, {{b, c}, d}, e}, {1} ] (* {{{b, c}, d}, e} *) (* same as *) Delete[ {a, {{b, c}, d}, e}, {{1}} ] (* {{{b, c}, d}, e} *)
Delete Multiple Items by Position
Delete[expr, {pos1, pos2, pos3, etc}]-
Delete multiple items by a list of their Positions
Delete[ {a, {{b, c}, d}, e}, {{1}} ] (* {{{b, c}, d}, e} *) Delete[ {a, {{b, c}, d}, e}, {{2}} ] (* {a, e} *) Delete[ {a, {{b, c}, d}, e}, {{1}, {2}} ] (* {e} *) Delete[ {a, {{b, c}, d}, e}, {{2, 1}} ] (* {a, {d}, e} *) Delete[ {a, {{b, c}, d}, e}, {{2, 1, 1}} ] (* {a, {{c}, d}, e} *)
Delete by Predicate or Pattern
SelectCasesDeleteCases
Delete Duplicates
DeleteDuplicates-
DeleteDuplicates[expr]DeleteDuplicates[expr,test]
Delete duplicates
DeleteDuplicates[ {3, x, 3, x, 4 } ] (* {3, x, 4} *)
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