diff options
author | Nick Shipp <nick@shipp.ninja> | 2017-05-07 09:04:01 -0400 |
---|---|---|
committer | Nick Shipp <nick@shipp.ninja> | 2017-05-07 09:04:01 -0400 |
commit | c012f55efda29f09179e921cf148d79deb57616e (patch) | |
tree | ff0ad37f22622d51194cab192a2aa4b0106d7ad0 /vim/bundle/slimv/swank-clojure/swank/util/string.clj | |
parent | 4ca8f6608883d230131f8a9e8b6d6c091c516049 (diff) |
Much maturering of vim configs
Diffstat (limited to 'vim/bundle/slimv/swank-clojure/swank/util/string.clj')
-rw-r--r-- | vim/bundle/slimv/swank-clojure/swank/util/string.clj | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/vim/bundle/slimv/swank-clojure/swank/util/string.clj b/vim/bundle/slimv/swank-clojure/swank/util/string.clj new file mode 100644 index 0000000..3250a61 --- /dev/null +++ b/vim/bundle/slimv/swank-clojure/swank/util/string.clj @@ -0,0 +1,16 @@ +(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))))
\ No newline at end of file |