WJ wrote:
> Ed L. Cashin wrote:
> > Good luck. I'm happy so far. Some people diss the"loop" macro, but
> > I've been delighted by it. This kind of thing is a real treat for me
> > (it was ugly as sin when I did it in Java):
> > (loop for c in player-cards
> > sum (card-blackjack-value c) into n
> > count (is-ace c) into n-aces
> > finally (return (if (and (> n-aces 0) (< n 12))
> > (+ n 10)
> > n)))))
> Clojure:
> (let [n (apply + (map card-blackjack-value player-cards))]
> (+ n (if (and (some is-ace player-cards) (< n 12)) 10 0)))
Racket:
(let ((n (for/sum ([c player-cards]) (card-blackjack-value c))))
(+ n (if (and (ormap is-ace player-cards) (< n 12)) 10 0)))