Skip to content

Instantly share code, notes, and snippets.

@bhenry
Created April 29, 2010 01:22
Show Gist options
  • Save bhenry/382990 to your computer and use it in GitHub Desktop.
Save bhenry/382990 to your computer and use it in GitHub Desktop.
(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