I write small card game and i want my code to be very explicit and therefore make it clear on a high level, that there are rounds to play. My first implementation was:
(defn play-game []
(->
(myio/initialize-cards-and-players)
(shuffle-and-share-cards myio/myshuffle)
;(announce)
(play-rounds)
)
)
I want the play rounds to be more explicit and show, that it is a loop on top-level:
(defn play-game []
(->>
(myio/initialize-cards-and-players)
(shuffle-and-share-cards myio/myshuffle)
(announce)
(loop [round 1]
(play-round-with-game round)
(if (<= round 4)
(recur (+ round 1))
)
)
; (play-round-with-game 2)
; (play-round-with-game 3)
; (play-round-with-game 4)
)
)
But i somehow cannot get the "game" object, that is returned by every function into the loop. Is there a good way to handle this with thread-last?
Or is there a way to use reduce instead of the loop?
loopinto its own binding within aletform. Or extract the collection preparation into its own function. The dumber the solution to this specific problem is, the better.