remove is a Clojure sequence function for excluding items whose predicate returns a truthy value. It returns a potentially empty lazy sequence, preserving items for which the predicate is false. The predicate is required, must accept one argument, and should preferably be free of side effects because laziness does not guarantee once-only invocation. section 3.5.3
Use remove with either of these arities:
- (remove pred) returns a transducer-producing function for use in a transducer pipeline. section 7.2
- (remove pred coll) processes any sequential collection and returns a lazy sequence no larger than the input. section 3.5.3
- Place removal early in processing pipelines when eliminating unwanted elements can avoid more expensive transformations. section 3.5.3
Removing matching values
(remove even? [1 2 3 4 5]) ;; (1 3 5) The predicate identifies elements to omit, so remove even? keeps the odd values. filter expresses the complementary operation by keeping predicate matches. section 3.5.3
Listing 3.27. → Sequence Processing, Items Selection
(filter ([pred]) ([pred coll])) (remove ([pred]) ([pred coll]))
Browse the compact signatures for remove and its related filter function, including their one- and two-argument forms. section 3.5.3
