On 02/03/2012 12:34 AM, Alex Baranosky wrote:
Hi Manuel,
Your second version looks pretty solid:
https://bitbucket.org/manuelp/geo-quiz/src/a75d57d0e5a2/src/geo_quiz/core.clj
You might consider getting rid of the vars for capitals, ask-capital,
and ask-capitals and using a let or letfn instead.
Thank you very much for your feedback Alex! Sorry for the late response,
I was sick.
I've incorporated your suggestions, now the short program is even
shorter. Nice! Using letfn to encapsulate functions used only by quiz
probably is a good strategy.
For binding both vars and functions, what's preferred? Using only let
for both:
(let [capitals [...]
ask-capital (fn [] ...)
...)
or instead let coupled with letfn?
(let [capitals [...]]
(letfn [(ask-capitals [...))
You don't need a do inside of ask-capital.
Yes it's not needed, but as I see it this way it's more explicit about
side effects. As I've read in books and clojuredocs this special form is
particularly well suited to this cases.
Another thing I see off hand is a huge nitpick on my part is that it is
not idiomatic to use:
(question :country) ... (:country question) is much more the norm.
I wasn't aware of this, thank you :)
Best,
Alex
Thanks again,
Manuel
--
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