Skip to content

Instantly share code, notes, and snippets.

@ponzao
Created March 24, 2011 10:18
Show Gist options
  • Save ponzao/884841 to your computer and use it in GitHub Desktop.
Save ponzao/884841 to your computer and use it in GitHub Desktop.
Explicit looping solution for the StringUtils.indexOfAny -problem.
(defn index-of-any [coll pred]
(loop [index 0
items coll]
(when (not (empty? items))
(if (pred (first items))
index
(recur (inc index) (rest items))))))
(index-of-any "foobar" #{\c \d \b}) ; -> 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment