验证中...
Languages: Clojure
Latest update 2018-12-09 09:55
countWord.clj
Raw Copy
;/**
; * 输入:1a2b1c1d1a
; * 输出:aaabbcda
; * @param str
; */
(defn decryptWord [s]
(apply str (flatten (map #(repeat % %2)
(map #(java.lang.Integer/parseInt %) (clojure.string/split s #"\D"))
(filter #(not (clojure.string/blank? %)) (clojure.string/split s #"\d")))))
)
;/**
; * 输入:aaabbcda
; * 输出:3a2b1c1d1a
; * @param str
; */
(defn countWord [s]
(->> s
(partition-by identity)
(map #(str (count %) (first %)))
(apply str)
)
)

Comment list( 0 )

You need to Sign in for post a comment

Help Search