WolframLang: Misc List Operations
Check Existence
MemberQ
- Check existence by Pattern MemberQ
Count
- Count by Pattern Count
Get the Position of a Element
Position[expr, pattern]
-
Return a list of positions that
Pattern
occur in expression.
If not exist, return a empty list.
Position
xx = {a, {{b, c}, a}, e}; (* position of e is {3} *) Position[ xx, e ] === {{3}} (* position of a is {1} and {2, 2} *) Position[ xx, a ] === {{1}, {2, 2}} (* when not found, empty list *) Position[ xx, m ] === {} (* position of b *) Position[ xx, b ] === {{2, 1, 1}} (* position of {b, c} *) Position[ xx, {b, c} ] === {{2, 1}}
Group into Sublists
Partition
-
Cut into sublist
Partition
x = Range[ 8 ]; Partition[ x, 2 ] === {{1, 2}, {3, 4}, {5, 6}, {7, 8}}
order
Sort
- Sort
SortBy
- SortBy
reverse
- reverse
RotateRight
-
shift all elements to the right, last item is moved to first.
RotateRight
RotateRight[ {1, 2, 3, 4} ] === {4, 1, 2, 3}
RotateLeft
- shift all elements to the left, first item is moved to last. RotateLeft
Ordering
-
return a list of integers that represent the ordering of the items.
Ordering
Ordering[ {a, c, b} ] === {1, 3, 2}
Join
→ concatenate lists JoinUnion
→ union of sets UnionIntersection
→ intersection of sets IntersectionComplement
→ subtract a set from other sets ComplementSubsets
→ all possible subsets Subsets
Tuples
→ Tuples
Permutations
→ Permutations