Re: Count vowels in a string

2014-05-22 Thread Brad Kurtz
keep is cool, thanks for showing me that :) On Wednesday, May 21, 2014 2:35:50 AM UTC-5, Vesa Marttila wrote: On Wednesday, May 21, 2014 2:03:14 AM UTC+3, Brad Kurtz wrote: I saw a rant online about interviewing developers that mentioned candidates not being able to count the number of

Re: Count vowels in a string

2014-05-21 Thread Vesa Marttila
On Wednesday, May 21, 2014 2:03:14 AM UTC+3, Brad Kurtz wrote: I saw a rant online about interviewing developers that mentioned candidates not being able to count the number of vowels in a string. So naturally, I decided to see if I could do it in Clojure! I wanted to see others' opinions

Re: Count vowels in a string

2014-05-21 Thread Plínio Balduino
My one cent: (defn count-vowels ([^String text] (count-vowels text aeiouAEIOU)) ([^String text ^String accepted-vowels] (let [vowel? (set accepted-vowels)] (- text (filter vowel?) count user= (count-vowels Plínio Balduino) 6 user= (count-vowels Plínio

Re: Count vowels in a string

2014-05-20 Thread Mark Engelberg
You're seriously overthinking this if it's any more than a one-liner. (defn count-vowels [s] (count (filter #{\a \e \i \o \u \A \E \I \O \U} (seq s On Tue, May 20, 2014 at 4:03 PM, Brad Kurtz bkurtz@gmail.com wrote: I saw a rant online about interviewing developers that mentioned

Re: Count vowels in a string

2014-05-20 Thread Ben Wolfson
The naïve implementation does sometimes underestimate the total, though. On Tue, May 20, 2014 at 4:13 PM, Mark Engelberg mark.engelb...@gmail.comwrote: You're seriously overthinking this if it's any more than a one-liner. (defn count-vowels [s] (count (filter #{\a \e \i \o \u \A \E \I \O \U}

Re: Count vowels in a string

2014-05-20 Thread Mark Engelberg
Why do you say that? On Tue, May 20, 2014 at 4:16 PM, Ben Wolfson wolf...@gmail.com wrote: The naïve implementation does sometimes underestimate the total, though. On Tue, May 20, 2014 at 4:13 PM, Mark Engelberg mark.engelb...@gmail.comwrote: You're seriously overthinking this if it's

Re: Count vowels in a string

2014-05-20 Thread Ben Wolfson
There are three vowels in naïve, not two. On Tue, May 20, 2014 at 4:19 PM, Mark Engelberg mark.engelb...@gmail.comwrote: Why do you say that? On Tue, May 20, 2014 at 4:16 PM, Ben Wolfson wolf...@gmail.com wrote: The naïve implementation does sometimes underestimate the total, though.

Re: Count vowels in a string

2014-05-20 Thread blake
To say nothing of y: yes - one vowel any - two vowels but the filter thing is good otherwise. -- 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

Re: Count vowels in a string

2014-05-20 Thread guns
On Tue 20 May 2014 at 04:22:17PM -0700, Ben Wolfson wrote: There are three vowels in naïve, not two. And watch out for those un-normalizable combining character combinations! Also, another one-liner: (defn ascii-vowel-count [s] (count (re-seq #(?i)[aeiou] s))) Doing this in a

Re: Count vowels in a string

2014-05-20 Thread Brad Kurtz
I like the one-liner. That was the kind of feedback I was looking for, thanks. On Tuesday, May 20, 2014 6:13:48 PM UTC-5, puzzler wrote: You're seriously overthinking this if it's any more than a one-liner. (defn count-vowels [s] (count (filter #{\a \e \i \o \u \A \E \I \O \U} (seq s

Re: Count vowels in a string

2014-05-20 Thread Mark Engelberg
On Tue, May 20, 2014 at 10:02 PM, Brad Kurtz bkurtz@gmail.com wrote: I like the one-liner. That was the kind of feedback I was looking for, thanks. On Tuesday, May 20, 2014 6:13:48 PM UTC-5, puzzler wrote: You're seriously overthinking this if it's any more than a one-liner. (defn