Filter
filter()
Filters elements in a list based on a condition.
- Type
- Details
The first argument is a test function, and the second argument is a list.
The return value is a list containing all the elements for which the test function returns true.
- Example
filter((v) => v == 1)([1, 1, 4, 5, 1, 4]); //[1, 1, 1]filter((v) => v == 1)([1, 1, 4, 5, 1, 4]); //[1, 1, 1]reject()
Filters elements in a list that do not meet a certain condition.
- Type
- Details
The first argument is a test function, and the second argument is a list.
The return value is a list containing all the elements for which the test function returns false.
- Example
reject((v) => v == 1)([1, 1, 4, 5, 1, 4]); //[4, 5, 4]reject((v) => v == 1)([1, 1, 4, 5, 1, 4]); //[4, 5, 4]shield()
Removes specified elements from a list.
- Type
- Details
The first argument is a list of elements to be removed (shield list), and the second argument is the list to be processed.
The return value is the list after removing the elements present in the shield list.
- Example
shield([1])([1, 1, 4, 5, 1, 4]); //[4, 5, 4]shield([1])([1, 1, 4, 5, 1, 4]); //[4, 5, 4]choose()
Selects specified elements from a list.
- Type
- Details
The first argument is a list of elements to be included (allow list), and the second argument is the list to be processed.
The return value is the intersection list of the list to be processed and the allow list.
- Example
choose([1])([1, 1, 4, 5, 1, 4]); //[1, 1, 1]choose([1])([1, 1, 4, 5, 1, 4]); //[1, 1, 1]