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 my-filter [pred? [x & xs :as a-seq]] | |
(if (empty? xs) | |
(when (pred? x) | |
a-seq) | |
(if (pred? x) | |
(cons x (my-filter pred? xs)) | |
(my-filter pred? xs)))) |
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 camel-case [string] | |
(loop [a "" | |
[h & [fr & lr :as r] :as s] string] | |
(cond | |
(empty? s) (apply str (reverse a)) | |
(and (= h \_) fr) (recur a (cons (Character/toUpperCase fr) lr)) | |
:else (recur (cons h a) r)))) | |
(camel-case "camel_case") ;camelCase | |
(camel-case "camel__case") ;camelCase |