Re: Count vowels in a string
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 vowels in a string. So naturally, I decided to see if I could do it in Clojure! I wanted to see others' opinions on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* Hi, I ended up with this: https://gist.github.com/ponzao/7399c08bb3b40d349289 (def vowels #{\a \e \i \o \u}) (defn count-vowels [s] (count (keep vowels (.toLowerCase s Vesa -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Count vowels in a string
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 on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* Hi, I ended up with this: https://gist.github.com/ponzao/7399c08bb3b40d349289 (def vowels #{\a \e \i \o \u}) (defn count-vowels [s] (count (keep vowels (.toLowerCase s Vesa -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Count vowels in a string
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 Balduino aeiouAEIOUíÍ) 7 I think this solves the problems for US-ASCII vowels and specific locale vowels. Plínio On Wed, May 21, 2014 at 4:35 AM, Vesa Marttila vtmartt...@gmail.com 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 vowels in a string. So naturally, I decided to see if I could do it in Clojure! I wanted to see others' opinions on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* Hi, I ended up with this: https://gist.github.com/ponzao/7399c08bb3b40d349289 (def vowels #{\a \e \i \o \u}) (defn count-vowels [s] (count (keep vowels (.toLowerCase s Vesa -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Count vowels in a string
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 on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Count vowels in a string
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 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 on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Count vowels in a string
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} (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 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 on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure. [Larousse, Drink entry] -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Count vowels in a string
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 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 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 on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure. [Larousse, Drink entry] -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Count vowels in a string
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. On Tue, May 20, 2014 at 4:13 PM, Mark Engelberg mark.engelb...@gmail.com 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 On Tue, May 20, 2014 at 4:03 PM, Brad Kurtz bkurtz@gmail.comwrote: 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 on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure. [Larousse, Drink entry] -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure. [Larousse, Drink entry] -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit
Re: Count vowels in a string
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 - 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Count vowels in a string
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 multilingual setting, as Ben Wolfson points out, would properly require a second parameter: the set of acceptable vowels in a given Language/Locale/Script (which are all different things). guns pgpCjnJtOko9u.pgp Description: PGP signature
Re: Count vowels in a string
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 On Tue, May 20, 2014 at 4:03 PM, Brad Kurtz bkurt...@gmail.comjavascript: 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 on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Count vowels in a string
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 count-vowels [s] (count (filter #{\a \e \i \o \u \A \E \I \O \U} (seq s Great, glad it was helpful. Actually, you can remove the call to seq, since filter calls it implicitly: (defn count-vowels [s] (count (filter #{\a \e \i \o \u \A \E \I \O \U} s))) On Tue, May 20, 2014 at 4:03 PM, Brad Kurtz bkurt...@gmail.com 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 on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@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+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.