diff --git a/.travis.yml b/.travis.yml index 9117050..d9bd985 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: clojure -lein: lein2 +lein: lein branches: only: - master diff --git a/src/main/clojure/stringly/core.clj b/src/main/clojure/stringly/core.clj index 8e2aa00..455209f 100644 --- a/src/main/clojure/stringly/core.clj +++ b/src/main/clojure/stringly/core.clj @@ -48,6 +48,10 @@ (let [xs (partition-by identity s)] (reduce #(if (> (count %1) (count %2)) %1 %2) '() xs)))) +(defn ^:api partition-count [s] + "https://twitter.com/Al_Grigor/status/1357028887209902088" + (->> (partition-by identity s) (map frequencies) seq)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; decimal-string? diff --git a/src/test/clojure/stringly/core_test.clj b/src/test/clojure/stringly/core_test.clj index 8b8d6ba..6a45a18 100644 --- a/src/test/clojure/stringly/core_test.clj +++ b/src/test/clojure/stringly/core_test.clj @@ -14,6 +14,7 @@ (substring? "aa" "bbaacc") => true (substring? "aa" "bbabcc") => false (longest-repeated-string "abbbbccccdeeeeeef") => "eeeeee" + (partition-count "aaaabbbcca") => [{\a 4} {\b 3} {\c 2} {\a 1}] (decimal-string? "1") => true (decimal-string? "a") => false (decimal-string? "-1") => true