Created
March 24, 2011 10:18
-
-
Save ponzao/884841 to your computer and use it in GitHub Desktop.
Explicit looping solution for the StringUtils.indexOfAny -problem.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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