1
0
Fork 0
mirror of synced 2024-11-15 13:38:58 -05:00
ultimate-vim/sources_non_forked/slimv/swank-clojure/swank/util/string.clj
2022-06-05 18:14:25 +08:00

16 lines
No EOL
547 B
Clojure

(ns swank.util.string)
(defn largest-common-prefix
"Returns the largest common prefix of two strings."
([#^String a, #^String b]
(apply str (take-while (comp not nil?) (map #(when (= %1 %2) %1) a b))))
{:tag String})
(defn char-position
"Finds the position of a character within a string, optionally
provide a starting index. Returns nil if none is found."
([c str] (char-position c str 0))
([#^Character c #^String str #^Integer start]
(let [idx (.indexOf str (int c) start)]
(when (not= -1 idx)
idx))))