Skip to content

Instantly share code, notes, and snippets.

@0rca
Last active August 29, 2015 14:12
Show Gist options
  • Save 0rca/0d91ee7e0953ad3fb7ac to your computer and use it in GitHub Desktop.
Save 0rca/0d91ee7e0953ad3fb7ac to your computer and use it in GitHub Desktop.
(defn numseq []
(->> (range) (map inc) (map #(.toString %)) (map seq) (flatten)))
(defn positions-of [el s]
(let [el' (-> el .toString seq)]
(->> s
(partition (count el') 1)
(map-indexed vector)
(filter (fn [[i x]] (= x el')))
(map (comp inc first)))))
(defn find-first [el s]
(first (positions-of el s)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment