Logo

Programming-Idioms

History of Idiom 135 > diff from v36 to v37

Edit summary for version 37 by programming-idioms.org:
Admin deletes impl 3955: No items

Version 36

2020-05-03, 21:28:07

Version 37

2020-05-03, 21:28:16

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Variables
items,x
Variables
items,x
Code
(let [coll [0 :a 2 3 4 :a 2 3 4]
      [left right] (split-with #(not= :a %) coll)]
  (concat left (rest right)))
Doc URL
https://clojuredocs.org/clojure.core/split-with