I am trying to write a GPA Calculator in Scheme language. The only part I think I am having problem with is the part in which I need to convert letters to integers within a list. I am using eq? in the code below because in one of his examples, our professor used eq? to convert a letter to an integer.
(define creditSum
(lambda (lst)
(if (or (not (list? lst)) (empty? lst))
0
(+ (car lst) (creditSum (cdr lst))))))
(define (gpa lst x)
(cond
((eq? x "A") 4.0)
((eq? x "B") 3.0)
((eq? x "C") 2.0)
((eq? x "D") 1.0)
((eq? x "F") 0.0)
(/ (creditSum x) (length x))))
I want to assign a number to each letter, and use those letters to get my output as an integer or decimal. For example if I input: (gpa '(A B A B)) my output should be 3.5.