Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Discard
Eliminate elements from a list for which a given conditional is True
Contributed by:
Taliesin Beynon
ResourceFunction["Discard"][list, crit] discards elements of list for which crit[elem] gives True. | |
ResourceFunction["Discard"][crit] is an operator form of ResourceFunction["Discard"] that can be applied to an expression. |
Examples
Basic Examples (1)
Discard all primes from a list of integers:
| In[1]:= |
| Out[1]= |
Properties and Relations (1)
If crit[elem] does not explicitly evaluate to False, elem is kept:
| In[2]:= | ![]() |
| Out[2]= |
Requirements
Wolfram Language 11.3 (March 2018) or above
Version History
- 1.0.0 – 13 December 2018
Related Symbols
License Information
This work is licensed under a Creative Commons Attribution 4.0 International License
![ResourceFunction["Discard"][Range[10], Which[
Mod[#, 3] === 0, True, Mod[#, 3] === 1, False,
Mod[#, 3] === 2, Indeterminate
] &]](https://cdn.statically.io/img/www.wolframcloud.com/obj/resourcesystem/images/f60/f60fb666-d568-4e85-a990-3d95b10b50be/1ae10063c8806d42.png)