Skip to content

Instantly share code, notes, and snippets.

@devn
Created May 2, 2013 07:07
Show Gist options
  • Save devn/5500611 to your computer and use it in GitHub Desktop.
Save devn/5500611 to your computer and use it in GitHub Desktop.
(defn remove-first [pred coll]
(let [[xs ys] (split-with (complement pred) coll)]
(concat xs (rest ys))))
(remove-first (partial = 3) [1 2 3 1 2 3])
;;; (1 2 1 2 3)
(remove-first even? [1 2 3 1 2 3])
;;; (1 3 1 2 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment