Created
September 29, 2011 05:51
-
-
Save mnzk/1250074 to your computer and use it in GitHub Desktop.
drop-start-same
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn drop-start-same | |
[ss] | |
(->> (loop [ss ss] | |
(if (apply = (map first ss)) | |
(recur (map rest ss)) | |
ss)) | |
(map (partial apply str)))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defn drop-start-same | |
[ss] | |
(let [chop-len (->> (apply map list ss) | |
(take-while (partial apply =)) | |
count) | |
chop (partial drop chop-len) | |
cs2str (partial apply str)] | |
(map (comp cs2str chop) ss))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; examples | |
;; | |
;; (drop-start-same ["abcdef" "abc123"]) | |
;; ;; => ("def" "123") | |
;; | |
;; (drop-start-same ["あいさんさん" "あいどる" "あいうえお" "あいんしゅたいん"]) | |
;; ;; => ("さんさん" "どる" "うえお" "んしゅたいん") | |
;; | |
;; (drop-start-same ["12345" "67890" "abc"]) | |
;; ;; => ("12345" "67890" "abc") | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment