Logo

Programming-Idioms

History of Idiom 135 > diff from v33 to v34

Edit summary for version 34 by misha:
New Clojure implementation by user [misha]

Version 33

2020-04-29, 16:39:04

Version 34

2020-04-29, 16:42:13

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.

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