Cases
The elements of a collection matching a pattern.
✓ checked against that system · ! checked, with disagreements (hover a chip)Fungrim
CasesWolfram LanguageCases✓Cases(collection, pattern)every element of that matches , in order.Typed signatures
| Type | Package | Applies |
|---|---|---|
(collection<any>, any) -> collection | combinatorics | always |
Details
- Matches compute-engine's own wildcards: a bare
_(or named,_a) matches any single element,__/___match one-or-more/zero-or-more within a structural pattern, and a pattern built from a head applied to wildcards (e.g. ) matches that structure. - A plain value (no wildcard) matches by exact equality, same as Count.
- Only the top level of the collection is searched.
Examples
Scope #
Possible issues #
compute-engine's wildcards carry no type: _Integer is just a named wildcard, so it matches every element
InOut
Wolfram's _Integer pattern only matches integers, here 2 (1 and 2).
About
| Examples | 5 |
|---|---|
| Checked against | Wolfram Language 2 agree1 unevaluated |
| Crosswalk | FungrimWolfram Language |