Last active
March 25, 2020 19:30
-
-
Save dosbol/fc520056b463336b0594c60602eb166f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| https://github.com/clojure/clojure/blob/b8c78ebf79b6a996f349dd112aaed658c132735d/src/clj/clojure/walk.clj | |
| *********************************************************************** | |
| "I'm" -> "I am" | |
| "They're" -> "they are" | |
| матчатся по реджексам. | |
| *********************************************************************** | |
| (as-> "They're I'm" s | |
| (clojure.string/replace s #"(['re]{3})" " are") | |
| (clojure.string/replace s #"(['m]{2})" " am")) | |
| *********************************************************************** | |
| (-> "They're I'm" | |
| (clojure.string/replace #"(['re]{3})" " are") | |
| (clojure.string/replace #"(['m]{2})" " am")) | |
| *********************************************************************** | |
| ((comp | |
| #(clojure.string/replace % #"(['re]{3})" " are") | |
| #(clojure.string/replace % #"(['m]{2})" " am")) | |
| "They're I'm") | |
| *********************************************************************** | |
| (defn fix-are [s] (clojure.string/replace s #"(['re]{3})" " are")) | |
| (defn fix-am [s] (clojure.string/replace s #"(['m]{2})" " am")) | |
| ((comp fix-are fix-am) "They're I'm") | |
| *********************************************************************** | |
| (defn replace [match replacement s] | |
| (clojure.string/replace s match replacement)) | |
| ((comp | |
| (partial replace #"(['re]{3})" " are") | |
| (partial replace #"(['m]{2})" " am")) | |
| "They're I'm") | |
| *********************************************************************** | |
| (def rules {#"(['re]{3})" " are" | |
| #"(['m]{2})" " am"}) | |
| (reduce-kv clojure.string/replace "They're I'm" rules) | |
| ************************************************************************ | |
| (filter some? [a b]) | |
| (remove nil? [a b]) | |
| (keep identity [a b]) | |
| (->> ... | |
| ... | |
| (filter (complement nil?))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment