cl-format has this built-in: (cl-format nil "~:(~a~)" "the quick brown fox") -> "The Quick Brown Fox"
Tom On Mar 8, 10:48 am, christophe turle <ctu...@yahoo.com> wrote: > my try : > > ;;; *** application code *** > > ;;; (my-capitalize "ab c") -> "Ab C" > ;;; (my-capitalize "ab") -> "Ab" > ;;; (my-capitalize "") -> "" > ;;; (def s "ab c") > (defn my-capitalize [s] > (words->string (map capitalize (string->words s))) ) > > ;;; *** libraries code *** > > ;;; (string->words "") -> [] > ;;; (string->words "ab") -> ["ab"] > ;;; (string->words "ab c") -> ["ab" "c"] > (defn string->words [s] > (if (.isEmpty s) > [] > (.split s " ") )) > > ;;; (capitalize "ab") -> "Ab" > ;;; (capitalize "c") -> "C" > ;;; (capitalize "") -> "" > ;;; (def s "ab") > (defn capitalize [s] > (if (.isEmpty s) > "" > (str (.toUpperCase (.substring s 0 1)) > (.toLowerCase (.substring s 1)) ))) > > ;;; (words->string '("A" "Bc")) -> "A Bc" > ;;; (words->string '()) -> "" > (defn words->string [words] > (apply str (interpose " " words)) ) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---