Thank you everyone for your critiques. This is exactly what I was
hoping for.

I must say my first Clojure experience (both with the language and the
community) has been excellent.

Stuart, your book is great. Worth every penny.

Cheers.

On May 10, 11:20 am, Christophe Grand <christo...@cgrand.net> wrote:
> Hello,
>
> In addition to Stuart's comments, I think your first+filter could be
> refactored in a call to "some" and that your map+filters could become fors.
>
> (defn get-subnet-from-args [args default]
>   (or (some #(when (re-find #"^\d" %) %) args) default))
>
> Or, you can rework your regex to match the whole string:
>
> (defn get-subnet-from-args [args default]
>   (or (some #(re-matches #"(?:\d\.)+" %) args) default))
>
> On map+filter:
>
> (defn available-ips [subnet]
>   (for [{:keys [ip exits]} :when (not exists)] ip))
>
> (defn used-ips [subnet]
>   (for [{:keys [ip exits]} :when exists] ip))
>
> hth,
>
> Christophe
>
> On Mon, May 10, 2010 at 1:32 PM, patrik karlin <patrik.kar...@gmail.com>wrote:
>
>
>
> > hello nott a expert my self
> > but *#*(:ip %) == :ip
> > and *#*(:exists %) == :exists
>
> > witch seems more idiomatic
>
> > 2010/5/9 Tim Morgan <seve...@gmail.com>
>
> > I picked up Programming Clojure by Stuart Halloway last week and am
> >> working through the book. I'm coming from a Perl/Python/Ruby
> >> background, so Java + Lisp + functional programming is all new to me.
>
> >> I thought a good exercise would be to write a script that pings all
> >> ips on a subnet looking for existing hosts, since I've written the
> >> same thing in Ruby before.
>
> >> The script I came up with is here:http://gist.github.com/395153
>
> >> It works (and it's considerably faster than my Ruby equivalent!), but
> >> I'm not certain it's idiomatic Clojure, and would love if someone
> >> could critique me a bit. Tear it apart.
>
> >> Thanks!
>
> >> -Tim Morgan
>
> >> --
> >> 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<clojure%2bunsubscr...@googlegroups.com>
> >> For more options, visit this group at
> >>http://groups.google.com/group/clojure?hl=en
>
> > --
> > ------------------------------------------------------------
> > Patrik Kårlin
> > Mobil: 0735165903
> > Email: patrik.kar...@gmail.com
> > ------------------------------------------------------------
>
> >  --
> > 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<clojure%2bunsubscr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
>
> --
> Brussels, 23-25/6http://conj-labs.eu/
> Professional:http://cgrand.net/(fr)
> On Clojure:http://clj-me.cgrand.net/(en)
>
> --
> 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 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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