Skip to content

Instantly share code, notes, and snippets.

@alandipert
Created May 2, 2013 04:15
Show Gist options
  • Save alandipert/5500118 to your computer and use it in GitHub Desktop.
Save alandipert/5500118 to your computer and use it in GitHub Desktop.
(defn remove-first
[pred coll]
(apply concat ((juxt take-while (comp rest drop-while)) (complement pred) coll)))
(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