Re: Uncle Bob: bowling meets Clojure

2009-07-24 Thread russellc
FWIW (i.e. IMO the previous two functional solutions are better examples) here is a more imperative style solution done sort of to prove to myself that I could do such a thing in Clojure w/o too much (arguable) fanfare. Maybe it will be interesting to others who are learning Clojure too (defn sc

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread Mark Triggs
An artifact of not running my code from a clean REPL before posting ;) It should just read `frames'. Cheers, Mark artg writes: > What is "group-frames"? > > --art > > On Jul 21, 12:00 am, Mark Triggs wrote: [...] >>   (defn score-game [rolls] >>     (reduce + (map #(reduce + %) >>        

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread artg
What is "group-frames"? --art On Jul 21, 12:00 am, Mark Triggs wrote: > Hi Stu, > > Stuart Halloway writes: > > Uncle Bob Martin, a very well-respected OO and agile guy, is learning   > > Clojure. He has posted an example [1] and asked for feedback from the   > > Clojure community. I have made

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread Jim Oly
On Jul 20, 7:01 pm, Mark Engelberg wrote: > Where is the original problem statement? It is hidden in Powerpoint slides (http://butunclebob.com/files/ downloads/Bowling%20Game%20Kata.ppt) linked on the description of the bowling game (http://butunclebob.com/ ArticleS.UncleBob.TheBowlingGameKata).

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread Stuart Halloway
Very nice! I would change the :satisfies clause for underachievers so that it does not create an ordering dependency. You should post this over on Uncle Bob's site. Stu > > Hi Stu, > > > Stuart Halloway writes: > >> Uncle Bob Martin, a very well-respected OO and agile guy, is learning >> Clo

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread Mark Triggs
Hi Stu, Stuart Halloway writes: > Uncle Bob Martin, a very well-respected OO and agile guy, is learning > Clojure. He has posted an example [1] and asked for feedback from the > Clojure community. I have made my suggestions in code [2] and will be > writing them up shortly. > > Would lov

Re: Uncle Bob: bowling meets Clojure

2009-07-20 Thread Stuart Halloway
Mark, I think your approach is clean and simple, but loses the advantage of decomposing the problem into useful constituent parts. I have written this up in more detail at http://blog.runcoderun.com/post/145675117/tdd-in-a-functional-language-uncle-bobs-bowling . Stu > I think you guys a

Re: Uncle Bob: bowling meets Clojure

2009-07-20 Thread Mark Engelberg
Where is the original problem statement? On Mon, Jul 20, 2009 at 11:16 AM, Jim Oly wrote: > > My main concern was that the problem statement doesn't just specify > the score function but also a roll function to accumulate the ball > rolls. --~--~-~--~~~---~--~~ Yo

Re: Uncle Bob: bowling meets Clojure

2009-07-20 Thread Jim Oly
My main concern was that the problem statement doesn't just specify the score function but also a roll function to accumulate the ball rolls. Obviously this will be different in Clojure since we would prefer immutable data structures, but it feels like we're losing part of the problem by ignoring

Re: Uncle Bob: bowling meets Clojure

2009-07-20 Thread Mark Engelberg
Sorry for the confusing choice of variable name. Should be "game" not "games" in: (defn score [game] (sum (take 10 (frame-scores game --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to th

Re: Uncle Bob: bowling meets Clojure

2009-07-20 Thread Mark Engelberg
Whoops, I guess I don't understand bowling scoring as well as I thought. Now that I've read up a bit more on bowling scoring, I see that if you get down to three rolls, (say 10, 7, 2) it must be scored differently depending on whether it is a strike in the 9th frame followed by 2 balls in the 10t

Re: Uncle Bob: bowling meets Clojure

2009-07-20 Thread Laurent PETIT
Hi Stuart, Couldn't your frames function benefit from using (when) instead of (if) (making it clear that the alternative is nil), and also, (when-let [rolls (seq rolls)]) instead of just (when rolls), which may be more robust and seems more idiomatic when used in conjunction with lazy-seq ? BTW,

Re: Uncle Bob: bowling meets Clojure

2009-07-20 Thread Mark Engelberg
I think you guys are really overthinking this problem. Because Clojure inherits Java's stack limitations, we tend to get hung up on converting elegant recursive code into loop/recur/accumulator structures. But here, we have a problem that we know isn't going to blow the stack, so just think recu

Uncle Bob: bowling meets Clojure

2009-07-20 Thread Stuart Halloway
Uncle Bob Martin, a very well-respected OO and agile guy, is learning Clojure. He has posted an example [1] and asked for feedback from the Clojure community. I have made my suggestions in code [2] and will be writing them up shortly. Would love to see what other folks on this list have to