0
Good evening, I’m starting now to learn Racket for college and I have an implemented function that I don’t understand why it’s not working. The goal is to receive a string and a character and return how many times the character appears in the string. ex: In "banana" the character "# a" appears 3 times, so the function should return 3. But I only have 0 to answer.
(define (numCaracter c s1 numC x)
(cond
[(equal? x (string-length s1)) numC]
[(equal? c (string-ref s1 x)) (numCaracter c s1 (add1 numC) (add1 x))]
[else (numCaracter c s1 numC (add1 x))]))
Even if worth mentioning I am testing the function as follows (numCaracter "# a" "banana" 0 0). Thanks for your attention.