you might submit this problem on 4clojure
 
i think you need regex for a short solution, something like
 

(*fn* [s] (clojure.string/join " " (map #(*let* [[_ c r] (re-find 
#"([^aeiouAEIOU]*)(\w*)" %)] (str r "-" c (*if* (empty? c) \w)"ay"))(
clojure.string/split s #"\s"))))
 
Am Mittwoch, 31. Oktober 2012 12:50:01 UTC+1 schrieb Sean S:

> Best I did wa*s *376 characters and that's with minifying*.
> ***
> http://codegolf.stackexchange.com/questions/8797/ode-cay-olf-gay/8856#8856
>
> Basically if the word starts with a vowel postfix "-ay"
> If it doesn't have any vowels postfix "ay"
> Otherwise take the first letter postfix "-" first letter "ay"
>
> (defn no-vowel [a b]
>     (reduce #(and % %2) (map #(= (.indexOf a %) -1) (map string/lower-case 
> (rest b)))))
>
> (defn transform [text]
>   (let [vowels ["a" "e" "i" "o" "u"]]
>     (if (> (.indexOf vowels (string/lower-case (first text))) -1)
>         (str text "-way")
>         (if (no-vowel vowels text)
>           (str text "ay")
>           (str (reduce str (rest text)) "-" (first text) "ay")))))
>
>
> (defn ay-ya [text]
>     (reduce str
>         (map #(str (transform %) " ")  
>              (string/split text #" ")))) 
>
>

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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

Reply via email to