From b1fd8241db94a337b706ca66e1bf626533d9da59 Mon Sep 17 00:00:00 2001 From: Noah Zucker Date: Thu, 4 Feb 2021 22:23:58 -0500 Subject: [PATCH 1/2] Dusting this off after ...8? years because another start up has a string problem to solve I guess? --- src/main/clojure/stringly/core.clj | 4 ++++ src/test/clojure/stringly/core_test.clj | 1 + 2 files changed, 5 insertions(+) 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 From b781973a0ae4d17e1873c285d1156c74918579bf Mon Sep 17 00:00:00 2001 From: Noah Zucker Date: Fri, 5 Feb 2021 09:11:53 -0500 Subject: [PATCH 2/2] Try to get build working with lein --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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