Created
April 29, 2010 01:22
-
-
Save bhenry/382990 to your computer and use it in GitHub Desktop.
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
(ns student.dialect | |
(use: [clojure.contrib.str-utils :only [str-join]])) | |
(defn babyize [s] "replace l and r with w if first letter of each word" | |
(let [b-word (fn [[first-letter & word]] | |
(let [new-first (cond (some #{first-letter} [\l \r]) \w | |
(some #{first-letter} [\L \R]) \W | |
:else first-letter)] | |
(apply str new-first word)))] | |
(str-join " " (map b-word (.split s " "))))) | |
(babyize "The little bunny went to the rail road for lunch with a rabbit.") | |
;; returns "The wittle bunny went to the wail woad for wunch with a wabbit." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment