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 freq-of-cha | |
[str] | |
(->> str | |
frequencies | |
(sort-by val >) | |
first | |
second | |
(vector str))) |
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
(add-hook 'clojure-mode-hook | |
'(lambda () | |
(font-lock-add-keywords | |
nil | |
'(("\\(\\<[a-zA-Z0-9\-\._\?]+\\>" 1 '(:foreground "red") t))))) |
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 char-diff | |
"the diff between char1 and (char21,char22)" | |
[char1 char21 char22] | |
(cond | |
(= char1 char21) 1 | |
(= char1 char22) 2 | |
:else 0)) | |
(defn word-chain? |
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
;;http://www.4clojure.com/problem/21 | |
#(loop [index 0 col %1] | |
(if (< index %2) | |
(recur (inc index) (next col)) | |
(first col))) |
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 increment | |
[str-chars] | |
(if ((complement empty?) str-chars) | |
(let [last-char (last str-chars) | |
ahead-chars (drop-last str-chars)] | |
(cond | |
(= last-char \9) (if (empty? ahead-chars) "10" (str (increment ahead-chars) \0)) | |
(= last-char \z) (if (empty? ahead-chars) "aa" (str (increment ahead-chars) \a)) | |
(= last-char \Z) (if (empty? ahead-chars) "AA" (str (increment ahead-chars) \A)) | |
:else (apply str (conj (vec ahead-chars) (char (inc (int last-char))))))) "")) |