Racket: Evaluate a hand in Blackjack

55 Views Asked by At

I am trying to create a function in DrRacket that evaluates a blackjack players hand. HOwever, when I used the following code:

(define (eval-hand hand)
  (let ([numAces 0] [ttl 0])
    (for/list ([i hand])
      (cond
        [(empty? hand) ttl]
        [(equal? (car i) 'A) (add1 numAces)]
        [(integer? (car i)) (+ (car i) ttl)]
        [else (+ ttl 10)]
        )))
)

(define playerhand '((2 Diamonds) (4 Clubs)))
(display (eval-hand playerhand))

I get (2 4) as my answer. What am I doing wrong? Please reply as soon as possible.

0

There are 0 best solutions below