Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Drop the largest values from a list based on a function
ResourceFunction["DropLargestBy"][list,f,n] drops the n elements ei in list for which f[ei] is largest. | |
ResourceFunction["DropLargestBy"][f,n] represents an operator form of ResourceFunction["DropLargestBy"]. |
Drop the largest two values:
In[1]:= |
Out[1]= |
Use the operator form, by first creating an operator op:
In[2]:= |
Out[2]= |
Apply the operator:
In[3]:= |
Out[3]= |
With n=0 nothing is deleted:
In[4]:= |
Out[4]= |
A negative number deletes the smallest n numbers:
In[5]:= |
Out[5]= |
If n is larger than the length of the list then an empty list is returned:
In[6]:= |
Out[6]= |
DropLargestBy is complementary to TakeLargestBy:
In[7]:= |
In[8]:= |
Out[8]= |
In[9]:= |
Out[9]= |
This work is licensed under a Creative Commons Attribution 4.0 International License